安装Node.js
我对node.js完全陌生 通过阅读文档和教程,我设法下载并安装node.js在我的窗口。
我如何testing并使其工作?
test.js文件保存在与node.exe相同的目录中,并包含:
console.log('Hello World');
打开我input的命令行:
$ node test.js
但是,没有什么hapenns,只是:
...
![在这里input图片描述] [1]我已经在nodejs shell中运行它,它只是工作
> console.log('Hello World'); Hello World undefined >
此外,我打开nodejs命令提示符不是Windows的默认命令提示符,然后
node path_to_file
它正在工作…相同的输出
您正在节点REPL中inputnode test.js
而不是命令行。 ...
表示尚未到达有效语句的末尾(因为您正在编写shell而不是JavaScript)。
用select的terminal仿真器运行命令行(如果使用Windows,可能是Windows Powershell)。
通过执行节点通过命令行运行节点REPL没有任何参数。 你没有得到预期的结果的原因可能是你直接运行node.exe
。 由于您正在使用Windows,请启动CMD
并从那里运行node.exe
。 一旦你运行了REPL,再次尝试node test.js
,这次它将工作。