npm全局安装不会在Windows 8.1上将软件包添加到PATH [英] npm global install does not add packages to PATH on Windows 8.1

查看:205
本文介绍了npm全局安装不会在Windows 8.1上将软件包添加到PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行npm install -g <package>时,它将软件包安装在我的用户/AppData/Roaming/npm/npm_modules/文件夹中.该子文件夹不在我的PATH中,因此,如果我尝试运行该程序包而不显式调用整个路径,则调用会失败,并显示'<package>' is not recognized as an internal or external command, operable program or batch file.

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.

该如何解决?

谢谢

推荐答案

我正在使用win8.1,我发现nodejs安装程序没有将指向全局节点模块的路径添加到系统PATH中.只需将%AppData%\npm;添加到用户变量(因为%AppData%目录取决于用户)PATH即可对其进行修复.

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.

您需要先注销然后重新登录,以使对PATH变量的更改生效.

You will need to log out then log back in for the change to your PATH variable to take effect.

SET PATH=%AppData%\npm;%PATH%

这篇关于npm全局安装不会在Windows 8.1上将软件包添加到PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆