Ubuntu - nodejs - npm install -g > Error: EACCES: permission denied, mkdir

后端 未结 2 505
难免孤独
难免孤独 2021-01-31 20:49

Was having a issue installing a NodeJS npm package. On a Digital-Ocean Droplet Ubuntu (14.04) server.

 npm install -g PACKAGE-NAME
<
相关标签:
2条回答
  • 2021-01-31 21:04

    Hope this helps someone took me a while to find a way to get this to install.

     sudo npm install -g PACKAGE-NAME --unsafe-perm=true --allow-root
    

    What the flags do:

    unsafe-perm - https://docs.npmjs.com/misc/config#unsafe-perm

    Default: false if running as root, true otherwise Type: Boolean Set to true to suppress the UID/GID switching when running package scripts. If set explicitly to false, then installing as a non-root user will fail.

    allow-root - https://bower.io/docs/api/#allow-root

    --allow-root Allows running commands as root. Bower is a user command, there is no need to execute it with superuser permissions. However, if you still want to run commands with sudo, use --allow-root option.

    0 讨论(0)
  • 2021-01-31 21:05

    For me, I didn't want to install npm for all the users. Hence wasn't using sudo npm .... Instead I granted the required permissions to the directory and it worked.

    sudo chmod -R ugo+rw ./node_modules/
    
    0 讨论(0)
提交回复
热议问题