When I run npm install -g <package>
it installs the packages in my user/AppData/Roaming/npm/npm_modules/ folder. This sub-folder is not in my PATH so if I try to run the package without explicitly calling the entire path the call fails with a '<package>' is not recognized as an internal or external command, operable program or batch file.
当我运行npm install -g
What can I do to fix this?
我该怎么做才能解决这个问题?
Thanks
谢谢
3 个解决方案
#1
21
I'm using win8.1 and I found that the nodejs installer didn't add the path to global node modules to the system PATH. Just add %AppData%\npm;
to the user variable(since %AppData% dir is depending on user) PATH
to fix it.
我正在使用win8.1,我发现nodejs安装程序没有将全局节点模块的路径添加到系统PATH。只需添加%AppData%\ npm;到用户变量(因为%AppData%dir取决于用户)PATH来修复它。
You will need to log out then log back in for the change to your PATH variable to take effect.
您需要注销然后重新登录才能使更改PATH变量生效。
#2
2
You have to run this line SET PATH=pathtonodejs;%PATH%
(where pathtonodejs
is where you installed nodejs) once the installation for nodejs is complete and it should work.
您必须运行此行SET PATH = pathtonodejs;%PATH%(其中pathtonodejs是您安装nodejs的位置)一旦nodejs的安装完成并且它应该工作。
#3
0
It turned the problem was a change in behavior of the module I was using.
它转变了问题是我正在使用的模块的行为的变化。
I'd been following old tutorials for using Express.js. The old tutorials assumed Express would be in my path after installing it globally, but as of Express v4.0 there's a separate Express module you have to install in order to get it in your path
我一直在关注使用Express.js的旧教程。旧的教程假设Express在全局安装后会在我的路径中,但是从Express v4.0开始,你必须安装一个单独的Express模块才能在你的路径中安装它
#1
21
I'm using win8.1 and I found that the nodejs installer didn't add the path to global node modules to the system PATH. Just add %AppData%\npm;
to the user variable(since %AppData% dir is depending on user) PATH
to fix it.
我正在使用win8.1,我发现nodejs安装程序没有将全局节点模块的路径添加到系统PATH。只需添加%AppData%\ npm;到用户变量(因为%AppData%dir取决于用户)PATH来修复它。
You will need to log out then log back in for the change to your PATH variable to take effect.
您需要注销然后重新登录才能使更改PATH变量生效。
#2
2
You have to run this line SET PATH=pathtonodejs;%PATH%
(where pathtonodejs
is where you installed nodejs) once the installation for nodejs is complete and it should work.
您必须运行此行SET PATH = pathtonodejs;%PATH%(其中pathtonodejs是您安装nodejs的位置)一旦nodejs的安装完成并且它应该工作。
#3
0
It turned the problem was a change in behavior of the module I was using.
它转变了问题是我正在使用的模块的行为的变化。
I'd been following old tutorials for using Express.js. The old tutorials assumed Express would be in my path after installing it globally, but as of Express v4.0 there's a separate Express module you have to install in order to get it in your path
我一直在关注使用Express.js的旧教程。旧的教程假设Express在全局安装后会在我的路径中,但是从Express v4.0开始,你必须安装一个单独的Express模块才能在你的路径中安装它