2017-01-26 142 views
-1

我目前正在通过“Learnyounode”学习Node。 然而,在我的电脑上测试一些JavaScript文件时,任何时候我尝试运行甚至一个简单的“Hello World”Console.log未定义

console.log("Hello World"); 

它给了我一个错误返回

Error: 'console' is undefined. 

这是一个问题我命令提示符或我系统上的错误?我需要重新安装Javascript吗?我的代码在我的浏览器控制台中正常工作,但不在我本地的命令行中。

任何帮助将不胜感激,提前致谢!

+0

看看下面的帖子,这可能会解释你看到的结果:http://stackoverflow.com/questions/8457389/node-js-displays-undefined-on-the-console –

+0

这是你的问题: http://osric.com/chris/accidental-developer/2016/06/node-js-error-console-is-undefined/ – Adam

+0

记得标记答案,如果它解决了你的问题接受:) [如何接受回答工作?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) –

回答

0

我知道有开始的NodeJS可能很难...尝试follwing:

1. Create a .js file... call it test.js 
2. In the file write command: 

    console.log('hello world from node'); 

3. save the file. 
4. Navigate to that directory and type: 

    node test.js 

Now you will see the output. 

祝您好运!

+0

谢谢!这是因为我没有用节点来领导它。输出工作,现在我要学习! – Gwinert

+0

太好了。我很高兴它帮助...祝你好运! :) – spooky

相关问题