Error: EACCES: permission denied

后端 未结 23 2217
醉梦人生
醉梦人生 2020-11-29 19:04

I run npm install lodash but it throws Error: EACCES: permission denied error. I know it is permission issue but as far as I know, sudo permission

相关标签:
23条回答
  • 2020-11-29 19:59

    I tried most of these suggestions but none of them worked. Then I ran npm clean-install and it solved my issues.

    0 讨论(0)
  • 2020-11-29 20:00

    I have same issue with webpack server installation on globally, Use steps from this Url Solved my issue, my be work for you.

    Steps mention above There: Back-up your computer before you start.

    Make a directory for global installations:

    1. mkdir ~/.npm-global

    Configure npm to use the new directory path:

    2.npm config set prefix '~/.npm-global'

    Open or create a ~/.profile file and add this line:

    3.export PATH=~/.npm-global/bin:$PATH

    Back on the command line, update your system variables:

    4.source ~/.profile

    Test: Download a package globally without using sudo.

    npm install -g jshint
    

    Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don't want to modify ~/.profile):

    NPM_CONFIG_PREFIX=~/.npm-global
    
    0 讨论(0)
  • 2020-11-29 20:03

    I solved this issue by changing the permission of my npm directory. I went to the npm global directory for me it was at

    /home/<user-name>
    

    I went to this directory by entering this command

    cd /home/<user-name>
    

    and then changed the permission of .npm folder by entering this command.

    sudo chmod -R 777 ".npm"
    

    It worked like a charm to me. But there is a security flaw with this i.e your global packages directory is accessible to all the levels.

    0 讨论(0)
  • 2020-11-29 20:04

    Try to give all permission to your project folder with below command

    sudo chmod -R 777 /yourProjectDirectoryName
    

    run with

    sudo npm install lodash
    
    0 讨论(0)
  • 2020-11-29 20:05

    Creating package.json using npm init solved my issue.

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