为什么“npm doctor”会产生权限错误?

oro*_*ome 7 npm

当我运行时,npm doctor我收到了以前从未见过的权限错误:

Perms check on local bin folder     not ok  Check the permissions of files in /Users/Orome/node_modules/.bin
Perms check on global bin folder    not ok  Check the permissions of files in /usr/local/bin
Run Code Online (Sandbox Code Playgroud)

我没有做任何我知道会导致此更改的更改。

是什么导致了这种情况,我该怎么办?


的完整输出npm doctor

npm WARN checkFilesPermission error getting info for /Users/Orome/node_modules/.bin
npm ERR! checkFilesPermission Missing permissions on /usr/local/bin/.keepme (expect: executable)
Check                               Value   Recommendation/Notes
npm ping                            ok
npm -v                              ok      current: v7.0.10, latest: v6.14.8
node -v                             ok      current: v15.2.0, recommended: v15.2.0
npm config get registry             ok      using default registry (https://registry.npmjs.org/)
which git                           ok      /usr/local/bin/git
Perms check on cached files         ok
Perms check on local node_modules   ok
Perms check on global node_modules  ok
Perms check on local bin folder     not ok  Check the permissions of files in /Users/Orome/node_modules/.bin
Perms check on global bin folder    not ok  Check the permissions of files in /usr/local/bin
Verify cache contents               ok      verified 9656 tarballs

npm ERR! Some problems found. See above for recommendations.
Run Code Online (Sandbox Code Playgroud)

配置:

macOS: 10.15.7-x86_64
CPU: quad-core 64-bit haswell
HOMEBREW_VERSION: 2.5.9-52-g8cffae8
HOMEBREW_PREFIX: /usr/local
Clang: 12.0 build 1200
Java: 1.8.0_172
CLT: 12.1.0.0.1.1602137645
Xcode: 12.1
Run Code Online (Sandbox Code Playgroud)

小智 6

对全局 bin 文件夹进行权限检查: npm doctor 在 /usr/local/bin/.keepme 文件上缺少可执行文件

这解决了我的问题:

chmod +x /usr/local/bin/.keepme
Run Code Online (Sandbox Code Playgroud)

对本地 bin 文件夹进行权限检查: 命令执行位置缺少 node_modules/.bin 文件夹,您可以手动创建它或使用命令:

mkdir node_modules && cd node_modules && mkdir .bin
Run Code Online (Sandbox Code Playgroud)


oro*_*ome 2

看来 Homebrew 和节点可能会不同步并因此产生此错误。无论如何简单地

npm install -g npm
Run Code Online (Sandbox Code Playgroud)

可能会照顾它。

如果失败,请确认其.keepme为空并尝试

rm -rf /usr/local/bin/.keepme
Run Code Online (Sandbox Code Playgroud)

  • 由于某种原因,它对我没有帮助。我得到以下输出: ``` up to date,audited 255 packages in 1s 11 packages arelooking forfunding run `npmfund` for detailsfound 0 issues ``` (4认同)