【问题标题】:Why does npm install not add search.cmd?为什么 npm install 不添加 search.cmd?
【发布时间】:2016-08-10 14:32:53
【问题描述】:

我在这里束手无策,无论我尝试什么,当找不到 Windows 命令文件 search.cmd 时,npm install 都会失败。这是我的输出

    npm ERR! Windows_NT 6.1.7601
    npm ERR! argv "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save"
    npm ERR! node v4.4.7
    npm ERR! npm  v2.15.8
    npm ERR! path c:\projects\sm\node_modules\.bin\search.cmd
    npm ERR! code EPERM
    npm ERR! errno -4048
    npm ERR! syscall open
    npm ERR! Error: EPERM: operation not permitted, open 'c:\projects\sm\node_modules\.bin\search.cmd'
    npm ERR!     at Error (native)
    npm ERR!  { [Error: EPERM: operation not permitted, open 'c:\projects\sm\node_modules\.bin\search.cmd']
    npm ERR!   errno: -4048,
    npm ERR!   code: 'EPERM',
    npm ERR!   syscall: 'open',
    npm ERR!   path: 'c:\\projects\\sm\\node_modules\\.bin\\search.cmd' }
    npm ERR!
    npm ERR! Please try running this command again as root/Administrator.
    npm ERR! Please include the following file with any support request:
    npm ERR!     c:\projects\sm\node_modules\npm-debug.log
    /c/Program Files/nodejs/npm: line 34: 12604 Signal 112              (core dumped) "$NODE_EXE" "$NPM_CLI_JS" "$@"

我正在运行 node -v 4.4.7。还尝试使用 5.11.0 和 6.3.1 也失败了。是的,我已经为每个人和他们的狗分配了对 node_modules 文件夹的完全控制权。

【问题讨论】:

  • 这个问题一直存在(据我所知)。我见过很多次,但只在 Windows 上。似乎与以下一项、多项或全部有关:旧的 npm 版本(有缺陷)、杀毒软件、慢速硬盘、权限、。如果可以的话,我会尝试最新的 npm 3.10.6,也许首先尝试使用 npm cache clean 以获得良好的衡量标准。我也看到了npm install -f 的推荐,这在过去对我有帮助。
  • 您的错误确实提到了Please try running this command again as root/Administrator,所以这也可能是一个因素
  • 我更新到 npm 3.10.6,以管理员身份运行 bash.exe,清理缓存,使用 --no-optional 强制安装,但仍然没有安装 search.cmd。
  • 您是否尝试过使用纯 DOS 命令提示符?我在 Windows 中使用 bash(以及 gitbash)遇到了同样的问题
  • 是的。结果相同。为了好玩,我将我的 npm 更新为 3.10.6,将节点更新为 6.3.1。用老式的 rm -fr * 清除了我的 node_modules 文件夹,更改为我的项目的根目录并再次运行 npm install。令我惊讶的是,它奏效了。

标签: node.js npm installation


【解决方案1】:

如果您以管理员身份运行代码,则问题出在 npm 缓存上。所以通过使用修复它

npm 缓存清理

命令。

您可以阅读有关此问题的更多信息here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-08
    • 1970-01-01
    • 2019-09-27
    • 2016-12-25
    • 2018-09-04
    • 2022-01-26
    • 2019-01-27
    相关资源
    最近更新 更多