sh: 1: node: Permission denied

前端 未结 7 536
闹比i
闹比i 2021-02-01 03:24

Tried to run this command on ubuntu 18.04

npm install -g pngquant-bin

but I got this error,

[..................] | fetchMetada         


        
相关标签:
7条回答
  • 2021-02-01 03:51

    Got the same error sh: 1: node: Permission denied

    So this worked for me

    npm config set user 0
    npm config set unsafe-perm true
    
    0 讨论(0)
  • 2021-02-01 03:53

    you need root user permission, just add sudo keyword before the command and write your password

    sudo npm install -g pngquant-bin
    
    0 讨论(0)
  • 2021-02-01 03:55

    The /root/.npm/... log path in your original message shows you're already running as root, and (despite what others advise) I'd say this is most likely causing your problem.

    My (limited) experience running Node as root is that most npm install runs get quite a long way, but then fail with some variation on the error you showed. The only reliable solution I've found is to not run Node or npm as root at all on Ubuntu. Just use a normal user account to download and unpack the Node installation.

    At least one problem with running as root for me turned out to be because some dependency-of-a-dependency npm install script was calling setuid to switch to a less-privileged user. For some reason, it chose UID 500—which doesn't exist on Ubuntu—and consequently lost all its privileges. The 'Permission denied' errors were therefore because I was running as root; setuid doesn't work for a normal user.

    I believe this is related to Error: setuid user id does not exist npm ERR! when npm install forever -g.

    0 讨论(0)
  • 2021-02-01 03:58

    I make the chown to project user owner (in USERID) dir and resolv the "permission denied" problem:

    sudo chown -R USERID.USERID *

    0 讨论(0)
  • 2021-02-01 03:58

    Additionally (and this might be useful for docker) you can override this configuration setting globally via the environment variable npm_config_user -- for example:

    ENV npm_config_user=root
    
    0 讨论(0)
  • 2021-02-01 04:07

    Try to install node at project folder

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