PureDevOps Community

Npm install core js postinstall sh: 1: node: Permission denied

In one of my react js project on doing npm install i got the following error , eventhough I was running as root user I got the error ( advise is to not run npm as root user)

sh: 1: node: Permission denied
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! pngquant-bin@5.0.0 postinstall: `node lib/install.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the pngquant-bin@5.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

The solution seems to be

npm config set user 0
npm config set unsafe-perm true

The only proper solution is to not run Node or npm as root at all on Ubuntu atleast . Just use a normal user account to download and unpack the Node installation