macOS uses npm to solve the permission problem encountered

I often see people saying "Why does npm install report an error, showing an EACCESS error...". Before, everyone used sudo to solve the problem, and they didn't care too much.
As for whether this problem is caused when brew installs tools, or when the system modifies disk permissions, or when it installs various gadgets, it's unknown... (I really don't want to pursue this)
When I'm working on generators recently, if I don't want to Include some files in the generator, then npm install will be called, so you will get an error...
The NPM maintainer's solution is:
https://github.com/npm/npm/issues/5922
Shell:
sudo chown-R` whoami`/usr/local

seems to have forgotten to clear the cache. Personally, it is recommended to modify the group permissions. Of course, if you have cleanliness, you can kill the .npm cache directory under /Users/whoami.

sudo chown-R`whoami`:staff/usr/local

sudo chown-R`whoami`:staff/Users/`whoami`/.npm
As for the node_modules in the project, it is recommended to rm and reinstall.
So far, enjoy using npm/cnpm.
Supplement (if you are in Greater China and npm is occasionally slow, you can use the NPM repository image of the conscience of the Taobao industry):
1
npm install-gcnpm--registry=http://registry.npm.taobao.org

Reprinted from: http://www.soulteary.com/2015/05/31/npm-on-macosx.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326887894&siteId=291194637