node.js 找不到快速命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23002448/
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 found
提问by Tony Barsotti
For some reason after installing Express globally on my machine with npm install -g expressif I cdinto a directory and try to run express I get the following error:
出于某种原因,在我的机器上全局安装 Express 后,npm install -g express如果我cd进入一个目录并尝试运行 express,我会收到以下错误:
express: command not found.
Even if I run it with sudoI still get the same output. I've tried multiple different solutions to this problem and nothing has worked. I had installed node via homebrewwhich some threads on Stack Overflow indicated might have been a problem so I completely uninstalled node and reinstalled via the installer on nodejs.org (I'm now running v0.10.26) and the problem still persists.
即使我用它运行它,sudo我仍然得到相同的输出。我已经尝试了多种不同的解决方案来解决这个问题,但没有任何效果。我已经安装了节点homebrew,Stack Overflow 上的一些线程表明可能存在问题,所以我完全卸载了节点并通过 nodejs.org 上的安装程序重新安装(我现在运行的是 v0.10.26),但问题仍然存在。
If I go into my /usr/local/lib/node_modulesExpress is in there but within /usr/local/bin there is nothing regarding Express. I'm not sure if that's a problem or not but considering there are binaries for other globally installed node packages in that directory I'm thinking there may be something wrong there.
如果我进入我的/usr/local/lib/node_modulesExpress 在那里,但在 /usr/local/bin 中,没有关于 Express 的任何内容。我不确定这是否有问题,但考虑到该目录中有其他全局安装的节点包的二进制文件,我认为那里可能有问题。
This is the exact output I get when I install:
这是我安装时得到的确切输出:
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/accepts/1.0.0
npm http GET https://registry.npmjs.org/type-is/1.0.0
npm http GET https://registry.npmjs.org/range-parser/1.0.0
npm http GET https://registry.npmjs.org/cookie/0.1.0
npm http GET https://registry.npmjs.org/fresh/0.2.2
npm http GET https://registry.npmjs.org/buffer-crc32/0.2.1
npm http GET https://registry.npmjs.org/send/0.2.0
npm http GET https://registry.npmjs.org/methods/0.1.0
npm http GET https://registry.npmjs.org/cookie-signature/1.0.3
npm http GET https://registry.npmjs.org/utils-merge/1.0.0
npm http GET https://registry.npmjs.org/merge-descriptors/0.0.2
npm http GET https://registry.npmjs.org/escape-html/1.0.1
npm http GET https://registry.npmjs.org/serve-static/1.0.1
npm http GET https://registry.npmjs.org/qs/0.6.6
npm http GET https://registry.npmjs.org/path-to-regexp/0.1.2
npm http GET https://registry.npmjs.org/parseurl/1.0.1
npm http GET https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/cookie/0.1.0
npm http 304 https://registry.npmjs.org/type-is/1.0.0
npm http 304 https://registry.npmjs.org/buffer-crc32/0.2.1
npm http 304 https://registry.npmjs.org/methods/0.1.0
npm http 304 https://registry.npmjs.org/accepts/1.0.0
npm http 304 https://registry.npmjs.org/range-parser/1.0.0
npm http 304 https://registry.npmjs.org/cookie-signature/1.0.3
npm http 304 https://registry.npmjs.org/fresh/0.2.2
npm http 304 https://registry.npmjs.org/serve-static/1.0.1
npm http 304 https://registry.npmjs.org/qs/0.6.6
npm http 304 https://registry.npmjs.org/utils-merge/1.0.0
npm http 304 https://registry.npmjs.org/merge-descriptors/0.0.2
npm http 304 https://registry.npmjs.org/escape-html/1.0.1
npm http 304 https://registry.npmjs.org/path-to-regexp/0.1.2
npm http 304 https://registry.npmjs.org/parseurl/1.0.1
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/send/0.2.0
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/send/0.1.4
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/negotiator
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/send/0.1.4
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/fresh/0.2.0
npm http 304 https://registry.npmjs.org/negotiator
npm http 304 https://registry.npmjs.org/range-parser/0.0.4
npm http 304 https://registry.npmjs.org/fresh/0.2.0
[email protected] /usr/local/lib/node_modules/express
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])
回答by PeterVC
With the release of Express 4.0.0 it looks like you need to do sudo npm install -g express-generator.
随着 Express 4.0.0 的发布,您似乎需要这样做sudo npm install -g express-generator。
回答by tearrain
You need to run:
你需要运行:
npm install -gd express-generator
The original express with cli, now the cli split into separate express-generator package. Originally generated by the project is running express node app.js, because httpserver relevant code in app.js, and now this part of the code to the project directory bin/wwwbelow, app.js retain only achieve app logic code, you need to run the bin/www. Just a very simple application and refinement package dependency version changes.
原来用 cli 表示 express,现在 cli 拆分成单独的 express-generator 包。本来项目生成的就是运行express node app.js,因为httpserver相关代码在app.js中,现在这部分代码到项目目录bin/www下面,app.js只保留实现app逻辑的代码,需要运行bin/www. 只是一个非常简单的应用程序和细化包依赖版本的变化。
回答by HilmaStac
I was having this challenge for a number of days. After deep search, I learned that one has to read every available resource especially from the parent source [in this case EXPRESSJS.COM]. Here is a quick fix.
几天来我一直在接受这个挑战。经过深入搜索,我了解到必须读取所有可用资源,尤其是从父源 [在这种情况下为 EXPRESSJS.COM]。这是一个快速修复。
Beginning with version 4.0+ you don't necessarily need to install express-generator if you are running Node 8.2+. Simply run
从 4.0+ 版本开始,如果您运行的是 Node 8.2+,则不一定需要安装 express-generator。只需运行
npx express-generator
The express-generator will run just the way it runs when you run:express
express-generator 将按照您运行时的运行方式运行:express
For more details see Getting Started
有关更多详细信息,请参阅入门
Happy reading and research hours.
愉快的阅读和研究时间。
回答by TheSYNcoder
I have been recently trying to install express-generator , however it would give out ,
我最近一直在尝试安装 express-generator ,但是它会给出,
$ zsh : command not found : express
It was after i did
是在我做了之后
$ sudo npm install -g express
$ sudo npm install -g express-generator
But then , i saw the console log of the npm install commnand
但是后来,我看到了 npm install commnand 的控制台日志
/usr/local/Cellar/node/13.1.0/bin/express -> /usr/local/Cellar/node/13.1.0/lib/node_modules/express-generator/bin/express-cli.js
which gave a hint that the executable express is in the bin folder.
这暗示了可执行快递位于 bin 文件夹中。
So the solution is : Open up ~/.zshrc or ~/.bashrc and export the path as follows:
所以解决办法是:打开~/.zshrc或者~/.bashrc,导出路径如下:
export PATH=/usr/local/Cellar/node/13.1.0/bin:$PATH
It works now.
它现在有效。

