Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does 'npm doctor' produce permission errors?

Tags:

npm

When I run npm doctor I get permission errors that I have not seen before:

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

I've made no changes that I'm aware of that would have caused this change.

What is causing this and what can I do about it?


Full output of 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.

Config:

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
like image 385
orome Avatar asked Nov 12 '20 16:11

orome


People also ask

Is it possible to fix the permissions of NPM?

This indicates that you do not have permission to write to the directories that npm uses to store global packages and commands. You can fix this problem using one of three options: Change the permission to npm's default directory. Change npm's default directory to another directory.


2 Answers

In my case, after updating npm, I found that the .bin directory does not exist. You just need to create: mkdir /Users/<username>/node_modules/.bin

like image 53
Mandrichenko Avatar answered Sep 25 '22 15:09

Mandrichenko


Perms check on global bin folder: npm doctor is missing executable on /usr/local/bin/.keepme file

This solves the problem in my case:

chmod +x /usr/local/bin/.keepme

Perms check on local bin folder: the node_modules/.bin folder is missing from the command execution location, you can create it manually or command:

mkdir node_modules && cd node_modules && mkdir .bin
like image 44
szeveba Avatar answered Sep 23 '22 15:09

szeveba