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

前端 未结 5 662
孤城傲影
孤城傲影 2020-12-23 22:46

I am trying to install monaca with this command.

npm install -g monaca

But right after getting these errors:



        
相关标签:
5条回答
  • 2020-12-23 23:24

    it is very simple you can use

    sudo npm install -g monaca

    or

    su -

    then

    npm install -g monaca

    explenation

    su -
    

    makes you as root ,who have permission to read , write and delete in all users click here for the screen shot showing the error and the solution in the update of npm

    this is for ubuntu i don't know is it work for other os
    
    0 讨论(0)
  • 2020-12-23 23:25

    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

    0 讨论(0)
  • 2020-12-23 23:34

    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

    0 讨论(0)
  • 2020-12-23 23:34

    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.

    0 讨论(0)
  • 2020-12-23 23:47

    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

    0 讨论(0)
提交回复
热议问题