Giingu
Giingu

Reputation: 81

sh: 1: node-gyp-build: Permission denied and npm ERR! code ELIFECYCLE npm ERR! errno 126

Tried to run this on Ubuntu 18.04 x64. It used to work properly a day ago but it stopped out of nowhere.

npm i simple-youtube-api

I used to be able to install them but not anyone, im getting this:

> [email protected] install /root/NezukoBot/node_modules/bufferutil
> node-gyp-build

sh: 1: node-gyp-build: Permission denied
npm WARN [email protected] requires a peer of @discordjs/uws@^10.149.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of sqlite@^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/pm2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/mocha/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! [email protected] install: `node-gyp-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the [email protected] install 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/2020-07-02T12_58_27_816Z-debug.log

I have tried this but i still get the error:

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

Upvotes: 8

Views: 13361

Answers (3)

Konard
Konard

Reputation: 3034

In my case, I solved the problem with permissions using latest version of npm:

npm i -g npm@latest

Upvotes: 3

Mikko Ohtamaa
Mikko Ohtamaa

Reputation: 83616

NPM is careful when installing packages as root.

Installing global packages as root or sudo can potentially damage your operating system, as it may accidentally replace files critical to the operating system itself.

However if you still want to proceed, you know what you are doing and you are e.g. using a virtual machine, you can do.

npm install --unsafe-perm -g simple-youtube-api

See unsafe-perm documentation.

Upvotes: 3

user2419098
user2419098

Reputation: 1

Just try to run the command under a user other than root.

https://timjrobinson.com/fixing-node-gyp-permission-denied-when-running-as-root/

Upvotes: -1

Related Questions