[英]Console.log is undefined
I'm currently in the process of learning Node via "Learnyounode".我目前正在通过“Learnyounode”学习 Node。 However, when testing some javascript files on my computer, anytime I try to run even a simple "Hello World"
但是,在我的计算机上测试一些 javascript 文件时,任何时候我都会尝试运行一个简单的“Hello World”
console.log("Hello World");
It gives me an error returning它给了我一个错误返回
Error: 'console' is undefined.
Is this a problem with my Command prompt or an error on my system?这是我的命令提示符的问题还是我的系统错误? do I need to re-install sometime for Javascript?
我需要重新安装 Javascript 吗? my code works fine in my Browser console, but not in my local Command lines.
我的代码在我的浏览器控制台中运行良好,但在我的本地命令行中不起作用。
Any help would appreciated, Thanks in advance!任何帮助将不胜感激,提前致谢!
I know starting with NodeJS can be difficult... Try the follwing:我知道从 NodeJS 开始可能很困难......试试以下:
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.
Good Luck!祝你好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.