Tried to run this command on ubuntu 18.04
npm install -g pngquant-bin
but I got this error,
[..................] | fetchMetada
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.