I am new to both Node JS and express, and I have just installed npm in Windows 7.
我是Node JS和express的新成员,我刚刚在Windows 7中安装了npm。
I have installed express using the global flag:
我已经安装了使用全球标志的快递:
npm install -g express
This sucessfully installs express in C:\Users\USER_NAME\AppData\Roaming\npm\node_modules\express
, and adds C:\Users\USER_NAME\AppData\Roaming\npm
to my path.
这成功地安装表达C:\Users\USER_NAME\AppData\Roaming\npm\ node_modules \表达,并将C:\Users\USER_NAME\AppData\Roaming\npm添加到我的路径。
However, using express in the command line is not successful. Any command starting with express tells me it cannot find the command to execute:
但是,在命令行中使用express并不成功。任何以express开头的命令都告诉我,它无法找到执行的命令:
'express' is not recognized as an internal or external command,
operable program or batch file.
Looking in the installation folder, I can't find an executable file either (an .exe or a .cmd). Googling past questions shows that the node_modules folder (at least in past versions) should contain both an express folder (which I have) and a .bin
folder, which contains express.cmd
. I don't appear to have the .bin
folder.
查看安装文件夹,我也找不到可执行文件(.exe或.cmd)。google过去的问题显示,node_modules文件夹(至少在过去的版本中)应该包含一个express文件夹(我有)和一个.bin文件夹,其中包含express.cmd。我好像没有。bin文件夹。
npm --version
gives me 1.4.3. Express version looks to be 3.0.0
npm——版本给我1.4.3。Express的版本看起来是3.0.0。
I've also tried installing it locally, and I've tried running npm cache clean
and reinstalling. Neither method changes the situation: there's nothing executable in the node_modules folder.
我也尝试在本地安装它,并且我尝试运行npm缓存清理和重新安装。两种方法都不能改变情况:node_modules文件夹中没有可执行文件。
Am I installing express incorrectly? If so, why does it not include an executable file?
我在安装快车吗?如果是,为什么不包含可执行文件?
7 个解决方案
#1
84
I ran into the same problem on Windows 8.1. The express.cmd is not created, but I found the text file:
我在Windows 8.1上遇到了同样的问题。表达。cmd没有创建,但是我找到了文本文件:
C:\Users\you\AppData\Roaming\npm\node_modules\express\Readme.md
It suggests to run this:
它建议运行这个:
npm install -g express-generator@3
Which will download more stuff.
这将会下载更多的东西。
After that you can use express on the windows command prompt. It will be in your path ( C:\Users\you\AppData\Roaming\npm)
之后,可以在windows命令提示符上使用express。它将在你的路径(C:\Users\you\AppData\Roaming\ npm)
Edit:
编辑:
express-generator@3
is now updated to express-generator@4
, so use this instead,
express-generator@3现在被更新到express-generator@4,所以使用它,
npm install -g express-generator@4
The answer isn't complete, because the modules are installed in C:\Users\you\AppData\Roaming\npm
directory as stated above, and you cannot always access any module without, 1) linking it to your current project or 2) explicityly defining the NODE_PATH
system variable pointing your node to the right place in the system.
答案并不完整,因为模块是安装在C:\Users\you\AppData\Roaming\npm目录如上所述,你不能总是访问任何模块,1)链接到你当前的项目或2)明显地定义NODE_PATH系统变量节点指向系统中正确的位置。
First method,
第一个方法,
After installing the module (express
in our case), you can link it to your current project by going to your current project directory using cmd and executing below command,
在安装了模块(在我们的例子中表示)之后,您可以通过使用cmd并执行以下命令将其链接到您当前的项目中,
npm link express
You will get a message like this if it is successfully linked,
如果链接成功,就会得到这样的消息,
D:\Project\node_modules\express -> C:\Users\Sufiyan\AppData\Roaming\npm\node_modules\express
项目D:\ \ node_modules \表达- > C:\Users\Sufiyan\AppData\Roaming\npm\ node_modules \表达
(you cannot link directories without running cmd with Administrator privileges)
(如果没有带有管理员权限的cmd,就不能链接目录)
The second option is to create or update NODE_PATH system variable pointing your node to the right place in the system. Read this for details.
第二个选项是创建或更新NODE_PATH系统变量,将节点指向系统中的正确位置。读这个细节。
Also read this official Node.js documentation regarding the issue,
还要读取这个官方节点。关于这个问题的js文档,
http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/
http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/
#2
8
This is all you need to do:
这就是你需要做的:
C:\node> npm install -g express-generator
You can find this and much more at this detailed start up tutorial.
在这个详细的启动教程中,您可以找到更多的内容。
#3
5
To fix this you need to use:
要解决这个问题,你需要使用:
npm install -g express-generator@3
npm安装- g express-generator@3
It has been updated from the previous command:
它已从以前的命令更新:
npm install -g express
npm安装- g表达
#4
2
Just be aware that the version as return by the express --version command will be the version of express-generator, not express.
请注意,express- version命令返回的版本将是express-generator的版本,而不是express。
#5
0
I had this problem, Seems though we use -g it's ignored.
我有这个问题,似乎我们用-g它被忽略了。
I just copied contents of MyProject/source/vendor
to C:\Users\username\AppData\Roaming\npm
我只是复制的内容。/ /供应商C:\Users\username\AppData\Roaming\npm来源
Copy only needed folders inside node_modules (like: express, express-generator, bower, yo, gulp and packages that should be in PATH).
只需要在node_modules(如:express、express-generator、bower、yo、gulp和应该在PATH中的包)内复制所需的文件夹。
This problem really bothers everyone (or windows users?), npm programmers should solve it!
这个问题真的困扰着每个人(或者windows用户?),npm程序员应该解决它!
#6
0
Run cmd as administrator. It solved the 'express' not found problem in my case
作为管理员运行cmd。它解决了我的案件中没有发现的问题。
#7
0
npm link express
to link express from any directory to your project directory were node is, by default when you run npm install express
it would be installed in C:\Users\****\AppData\Roaming\npm\node_modules\express
, so you don't have to install express and other frameworks required to install each time in your project directory, instead you can point to your node i.e where you have your application.
npm链接表达表达从任何目录链接到您的项目目录节点,默认情况下,当您运行npm安装表达,它将被安装在C:\Users\****\AppData\Roaming\npm\ node_modules \表达,所以你不必每次安装所需表达和其他框架安装在你的项目目录中,而不是我可以指向您的节点。你在哪里有你的申请。
#1
84
I ran into the same problem on Windows 8.1. The express.cmd is not created, but I found the text file:
我在Windows 8.1上遇到了同样的问题。表达。cmd没有创建,但是我找到了文本文件:
C:\Users\you\AppData\Roaming\npm\node_modules\express\Readme.md
It suggests to run this:
它建议运行这个:
npm install -g express-generator@3
Which will download more stuff.
这将会下载更多的东西。
After that you can use express on the windows command prompt. It will be in your path ( C:\Users\you\AppData\Roaming\npm)
之后,可以在windows命令提示符上使用express。它将在你的路径(C:\Users\you\AppData\Roaming\ npm)
Edit:
编辑:
express-generator@3
is now updated to express-generator@4
, so use this instead,
express-generator@3现在被更新到express-generator@4,所以使用它,
npm install -g express-generator@4
The answer isn't complete, because the modules are installed in C:\Users\you\AppData\Roaming\npm
directory as stated above, and you cannot always access any module without, 1) linking it to your current project or 2) explicityly defining the NODE_PATH
system variable pointing your node to the right place in the system.
答案并不完整,因为模块是安装在C:\Users\you\AppData\Roaming\npm目录如上所述,你不能总是访问任何模块,1)链接到你当前的项目或2)明显地定义NODE_PATH系统变量节点指向系统中正确的位置。
First method,
第一个方法,
After installing the module (express
in our case), you can link it to your current project by going to your current project directory using cmd and executing below command,
在安装了模块(在我们的例子中表示)之后,您可以通过使用cmd并执行以下命令将其链接到您当前的项目中,
npm link express
You will get a message like this if it is successfully linked,
如果链接成功,就会得到这样的消息,
D:\Project\node_modules\express -> C:\Users\Sufiyan\AppData\Roaming\npm\node_modules\express
项目D:\ \ node_modules \表达- > C:\Users\Sufiyan\AppData\Roaming\npm\ node_modules \表达
(you cannot link directories without running cmd with Administrator privileges)
(如果没有带有管理员权限的cmd,就不能链接目录)
The second option is to create or update NODE_PATH system variable pointing your node to the right place in the system. Read this for details.
第二个选项是创建或更新NODE_PATH系统变量,将节点指向系统中的正确位置。读这个细节。
Also read this official Node.js documentation regarding the issue,
还要读取这个官方节点。关于这个问题的js文档,
http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/
http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/
#2
8
This is all you need to do:
这就是你需要做的:
C:\node> npm install -g express-generator
You can find this and much more at this detailed start up tutorial.
在这个详细的启动教程中,您可以找到更多的内容。
#3
5
To fix this you need to use:
要解决这个问题,你需要使用:
npm install -g express-generator@3
npm安装- g express-generator@3
It has been updated from the previous command:
它已从以前的命令更新:
npm install -g express
npm安装- g表达
#4
2
Just be aware that the version as return by the express --version command will be the version of express-generator, not express.
请注意,express- version命令返回的版本将是express-generator的版本,而不是express。
#5
0
I had this problem, Seems though we use -g it's ignored.
我有这个问题,似乎我们用-g它被忽略了。
I just copied contents of MyProject/source/vendor
to C:\Users\username\AppData\Roaming\npm
我只是复制的内容。/ /供应商C:\Users\username\AppData\Roaming\npm来源
Copy only needed folders inside node_modules (like: express, express-generator, bower, yo, gulp and packages that should be in PATH).
只需要在node_modules(如:express、express-generator、bower、yo、gulp和应该在PATH中的包)内复制所需的文件夹。
This problem really bothers everyone (or windows users?), npm programmers should solve it!
这个问题真的困扰着每个人(或者windows用户?),npm程序员应该解决它!
#6
0
Run cmd as administrator. It solved the 'express' not found problem in my case
作为管理员运行cmd。它解决了我的案件中没有发现的问题。
#7
0
npm link express
to link express from any directory to your project directory were node is, by default when you run npm install express
it would be installed in C:\Users\****\AppData\Roaming\npm\node_modules\express
, so you don't have to install express and other frameworks required to install each time in your project directory, instead you can point to your node i.e where you have your application.
npm链接表达表达从任何目录链接到您的项目目录节点,默认情况下,当您运行npm安装表达,它将被安装在C:\Users\****\AppData\Roaming\npm\ node_modules \表达,所以你不必每次安装所需表达和其他框架安装在你的项目目录中,而不是我可以指向您的节点。你在哪里有你的申请。