已安装全局 NPM 包但未找到命令 [英] Global NPM package installed but command not found

查看:79
本文介绍了已安装全局 NPM 包但未找到命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在全局安装了两个 npm 包 "download""enigmavirtualbox" 通过命令行:

I have globally installed two npm packages "download" and "enigmavirtualbox" via command line:

npm install -g 下载npm install -g engimavirtualbox

我正在尝试在批处理文件中使用它们来从我的节点项目中捆绑单个 .exe 文件.对于这两种情况,命令 npm list -g 产生各自的版本输出,独立于当前的工作目录.

I'm trying to use them in a batch file to bundle a single .exe file from my node project. For both, the commands npm list -g <packagename> yield the respective version output, independent of the present working directory.

但是,在我的批处理脚本中,找不到命令download"和enigmavirtualbox".

However, inside my batch script the commands "download" and "enigmavirtualbox" cannot be found.

运行 npm root -g 产生 C:UsersAppDataRoaming pm ode_modules 并查看该文件夹内我可以看到该文件夹两个包都存在.

Running npm root -g yields C:Users<username>AppDataRoaming pm ode_modules and looking inside that folder I can see that folders for both packages are present.

我尝试过的:

  • 按照此处npm root>
  • 卸载并重新安装软件包
  • 添加环境.变量 NODE_PATH 指向 C:UsersAppDataRoaming pm ode_modules
  • C:UsersAppDataRoaming pm ode_modules 添加到 PATH 环境.变量
  • Changing npm root as described here
  • Uninstall and reinstall packages
  • Add env. variable NODE_PATH to point to C:Users<username>AppDataRoaming pm ode_modules
  • Add C:Users<username>AppDataRoaming pm ode_modules to PATH env. variable

同样的设置在我的第二台电脑上工作(都运行 Win7 64 位).我的节点安装有问题,还是我做错了什么?

The same setup works on my second computer (both run Win7 64bit). Is something wrong with my node installation, or what am I doing wrong?

推荐答案

可执行二进制文件和 .cmd 文件最终位于 C:UsersAppDataRoaming pm (最后减去 node_modules ),因此将该路径添加到 PATH 环境中.变量解决了这个问题.

The executable binaries and .cmd files end up in C:Users<username>AppDataRoaming pm (minus the node_modules at the end) so adding that path to the PATH env. variable fixed the issue.

这篇关于已安装全局 NPM 包但未找到命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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