简体   繁体   English

node.js “找不到命令”

[英]node.js “Command not found”

I am attempting to work with node and learning how to write in Javascript.我正在尝试使用节点并学习如何在 Javascript 中编写。 I am currently trying to use my terminal to run a basic "Hello world" js file using node.我目前正在尝试使用我的终端使用 node.js 运行一个基本的“Hello world”js文件。 However, when I attempt to use $node index.js (that's what the file is called).但是,当我尝试使用 $node index.js (这就是文件的名称)时。 All the terminal responds with is index.js command not found.所有终端的响应都是 index.js 命令未找到。 I tried to do it with the just the terminal window, I have also tried to run it through the integrated terminal within data studio, so I am unsure of where I went wrong.我尝试仅使用终端 window 来执行此操作,我还尝试通过数据工作室中的集成终端运行它,所以我不确定我哪里出错了。

Here is a screen shot of my window.这是我的 window 的屏幕截图。

Remove the $ sign.删除$符号。 In web examples, docs use $ to show that you run it in the command line.在 web 示例中,文档使用$来表明您在命令行中运行它。

Instead use node index.js , or set up a package.json file and use npm start ( npm start should contain node index.js ). Instead use node index.js , or set up a package.json file and use npm start ( npm start should contain node index.js ).

Final Clarification (if you didn't understand the above explanation)最终澄清(如果您不理解上述解释)

Run node index.js .运行node index.js $ is never used, except to show you that the command is used in the command line. $从未使用过,只是向您显示该命令已在命令行中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM