node.js Express 命令在终端中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22975454/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Express command not working in terminal
提问by Max Baldwin
I am kind of new to node.js. I installed node fine and it works. I can run the node command in the terminal as well as the node package manager command(npm). Working on a Mac by the way. So I installed express globally with the following command:
我对 node.js 有点陌生。我很好地安装了节点,并且可以正常工作。我可以在终端中运行节点命令以及节点包管理器命令(npm)。顺便说一下,在 Mac 上工作。所以我使用以下命令全局安装了 express:
sudo npm install -g express
After I was done installing it globally I installed it in a small folder where I am working on a project.
在我完成全局安装后,我将它安装在我正在处理项目的一个小文件夹中。
sudo install express
That gave me a node_modules folder inside of my site folder. After I was done that I went to install stylus using the express command and I got the error that express is not a command.
这在我的站点文件夹中给了我一个 node_modules 文件夹。完成后,我使用 express 命令安装了手写笔,但出现 express 不是命令的错误。
express -c stylus
Can anyone shed some light on this issue? I also tried to link the global express to the folder where I am working on the project using the following command:
任何人都可以对这个问题有所了解吗?我还尝试使用以下命令将 global express 链接到我正在处理项目的文件夹:
sudo npm link express
The terminal said that this command ran, but I still cannot run the express command.
终端说这个命令运行了,但是我还是不能运行express命令。
回答by Max Baldwin
Thanks for asking questions on this one. I found that running express-generator instead of just express fixed the problem. The following code in the terminal worked.
感谢您就此提出问题。我发现运行 express-generator 而不是 express 解决了这个问题。终端中的以下代码有效。
sudo npm install -g express-generator
Thanks again,
再次感谢,
回答by Quentin Rufin
If your express binary keeps doing nothing. Install node-legacy:
如果你的 express 二进制文件一直什么都不做。安装节点遗留:
sudo apt-get install nodejs-legacy
sudo apt-get install nodejs-legacy
回答by djsharma
on ubuntu 14.04 nodejs 0.10 express did not work on terminal, though
在 ubuntu 14.04 上,nodejs 0.10 express 在终端上不起作用,但
sudo apt-get install nodejs-legacy
sudo apt-get install nodejs-legacy
made it to work.
让它工作。
回答by Vipul Lawande
I faced similar issue. I tried all the solutions mentioned here. However couldn't get my problem solved.
我遇到了类似的问题。我尝试了这里提到的所有解决方案。但是无法解决我的问题。
This happens when location of express and nodejs is not same.
当 express 和 nodejs 的位置不同时会发生这种情况。
Issue arises when Node is installed using homebrew.
使用自制软件安装 Node 时会出现问题。
Just use this command export PATH=/usr/local/share/npm/bin:$PATH
只需使用此命令 export PATH=/usr/local/share/npm/bin:$PATH
NOTE: replace path with the path of express.
注意:将 path 替换为 express 的路径。
Follow thislink for help.
按照此链接寻求帮助。
回答by karna
Make sure you have package.json& index.jsfiles. And instaled express-generatorwith -gtag.
If still getting error use like ex:npx express --view=pug myapp --git
确保你有package.json&index.js文件。并express-generator用-g标签安装。如果仍然出现错误,请使用像 ex:npx express --view=pug myapp --git

