npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules

旧时模样 提交于 2020-06-22 05:43:04

问题


I am trying to install monaca with this command.

npm install -g monaca

But right after getting these errors:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules npm ERR! path /usr/local/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/lib/node_modules' }

Any idea how to solve this problem? Thank you


回答1:


An inadvisable way to fix the issue would be to use sudo:

sudo npm install -g monaca

However it would be better to find a way around this without using sudo.

npm install -g less does not work




回答2:


add following lines to ~/.bashrc after installing npm:

npm set prefix ~/.npm
PATH="$HOME/.npm/bin:$PATH"
PATH="./node_modules/.bin:$PATH"

Execute following line after changes:

source ~/.bashrc

and as mentioned by @contemplator avoid using sudo




回答3:


Note: It is highly recommended to avoid using sudo with npm!

Using sudo is not recommended. It may give you permission issue later. While the above works, use these instructions to fix your issue permanently.




回答4:


Well, I used --save-dev and installed it not globally or using -g, the main problem occurs while you want it to write on default node_modules folder.

It solved my problem after 4 hours of checking multiple issues.

I even suggest you to use the npm init and make a package.json for a better dependency checking and then run npm install afterward. this video helps you for this https://www.youtube.com/watch?v=rTsz09zRuTU



来源:https://stackoverflow.com/questions/52979927/npm-warn-checkpermissions-missing-write-access-to-usr-local-lib-node-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!