Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sh: 1: node: Permission denied

Tags:

node.js

npm

Tried to run this command on ubuntu 18.04

npm install -g pngquant-bin

but I got this error,

[..................] | fetchMetadata: sill resolveWithNewModule [email protected] checking installable status
npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
/root/.nvm/versions/node/v10.8.0/bin/pngquant -> /root/.nvm/versions/node/v10.8.0/lib/node_modules/pngquant-bin/cli.js

> [email protected] postinstall /root/.nvm/versions/node/v10.8.0/lib/node_modules/pngquant-bin
> node lib/install.js

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

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-08-12T18_08_02_197Z-debug.log

Do you do you know how to deal with this? I tried every solution found in this articles yet not succeeded.

like image 485
Fil Avatar asked Aug 12 '18 18:08

Fil


3 Answers

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
like image 148
Rooney Avatar answered Nov 15 '22 12:11

Rooney


These issues happen because of broken packages. Go to the main folder. If using Linux use command

sudo rm -rf node_modules.

After that run this command if you are using yarn

yarn install

If you are using npm run this command

npm install
like image 29
ijaz khan Avatar answered Nov 15 '22 11:11

ijaz khan


Delete the node_modules and install it again

sudo rm -rf node_modules

npm install

like image 10
hemant raut Avatar answered Nov 15 '22 10:11

hemant raut