Error: EACCES: permission denied

后端 未结 23 2215
醉梦人生
醉梦人生 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:45

    Try using this: On the command line, in your home directory, create a directory for global installations:

    mkdir ~/.npm-global
    

    Configure npm to use the new directory path:

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

    In your preferred text editor, open or create a ~/.profile file and add this line:

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

    On the command line, update your system variables:

    source ~/.profile
    

    Test installing package globally without using sudo, Hope it helps

    0 讨论(0)
  • 2020-11-29 19:45

    node recommends executing following:

     sudo chown -R $USER:$(id -gn $USER) /home/venkatesh/.config
    

    If you execute

    npm config
    

    You will see something like this

    │                   npm update check failed                   │
    │             Try running with sudo or get access             │
    │            to the local update config store via             │
    │ sudo chown -R $USER:$(id -gn $USER) /home/venkatesh/.config │
    

    It worked for me.

    0 讨论(0)
  • 2020-11-29 19:47

    From what i can see in your logs you posted:

    npm ERR!   code: 'EACCES',
    npm ERR!   syscall: 'mkdir',
    npm ERR!   path: '/home/rupesh/node_modules/lodash',
    npm ERR!   fstream_type: 'Directory',
    npm ERR!   fstream_path: '/home/rupesh/node_modules/lodash',
    npm ERR!   fstream_class: 'DirWriter',
    

    directory /home/rupesh/node_modules/ doesn't have necessary permissions to create directory so run chown -r rupesh:rupesh /home/rupesh/node_modules/ this should solve it.

    0 讨论(0)
  • 2020-11-29 19:47

    Just change the owner of the global node_modules directory to be your user:

    sudo chown -R $USER:$GROUP /usr/local/lib/node_modules
    
    0 讨论(0)
  • 2020-11-29 19:50

    This command fix the issue. It worked for me:

    sudo npm install -g --unsafe-perm=true --allow-root
    
    0 讨论(0)
  • 2020-11-29 19:51

    It doesn't have write permissions for others (r-x). Try with

    chmod a+w <folder>
    

    and repeat.

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