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

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

问题描述

当我运行 npm install -g 时,它会在我的 user/AppData/Roaming/npm/npm_modules/文件夹中安装包.这个子文件夹不在我的 PATH 中,所以如果我尝试运行包而不显式调用整个路径,调用将失败并显示 '<package>'不是内部或外部命令,也不是可运行的程序或批处理文件.

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.

我该怎么做才能解决这个问题?

What can I do to fix this?

谢谢

推荐答案

我使用的是 win8.1,我发现 nodejs 安装程序没有将全局节点模块的路径添加到系统 PATH 中.只需将 %AppData% pm; 添加到 user 变量(因为 %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% pm; 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%
pm;%PATH%

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

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