[英]Why Node.js cannot run my JavaScript code in the terminal?
You have a >
before your text cursor.您的文本 cursor 之前有一个>
。 This means that you're already in Node .这意味着您已经在 Node 中。
Right now, what's happening is you're telling Node to run the following JavaScript:现在,发生的事情是您告诉 Node 运行以下 JavaScript:
node index.js
which, of course, is not valid JavaScript.当然,这不是有效的 JavaScript。
You need to exit Node so that the standard terminal is displayed, such as cmd or powershell (press Control-C a couple times)您需要退出 Node 以便显示标准终端,例如 cmd 或 powershell(按 Control-C 几次)
Then you can type in node index.js
.然后你可以输入node index.js
。 If you're in the same directory as the index.js
file, it'll execute.如果您与index.js
文件位于同一目录中,它将执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.