szymon
szymon

Reputation: 53

Error "Permission denied" after execute npm install

After executing npm install, occurs following error:

npm ERR! code 127
npm ERR! path /var/www/html/node_modules/core-js
npm ERR! command failed
npm ERR! command sh -c node -e "try{require('./postinstall')}catch(e){}"
npm ERR! sh: 1: node: Permission denied

I'm executing command as a root on Docker. I tried to set npm config set user 0 and npm config set unsafe-perm true but nothing changed.

Upvotes: 1

Views: 7985

Answers (2)

szymon
szymon

Reputation: 53

I changed files ownership to root, and after that everything work. chown -R root:root .

Upvotes: 2

yanir midler
yanir midler

Reputation: 2712

This is a common problem when you install packages using sudo. That's why you shouldn't install any package using sudo keyword.

The solution: Delete node_modules folder. If it says that you don't have permission then delete it directly from folder (not from IDE) or through the terminal.

After that install your packages again. This time only npm i without sudo.

Upvotes: 1

Related Questions