Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/serverless/node_modules/snappy/.node-gyp'

I have an AWS CodeBuild Project which tries to install serverless framework but returns an error in the title however it says framework successfully installed. My understanding is that this fails to install the snappy module. Why is that and how can I resolve this?

The command I run in my buildspec.yaml is:

npm install -g serverless

And my user is:

/root

enter image description here

like image 397
Ramin Avatar asked Oct 22 '25 13:10

Ramin


2 Answers

in the first error line:

gyp WARN EACCES current user ("nobody")...

seems node-gyp is trying to use another user instead of root,

we can find the issue discussed in the package repository:

  • https://github.com/nodejs/node-gyp/issues/1236

the most recent solutions seems to be:

npm_config_user=root npm install -g ...

to force/set the environment user to be used by npm install process

like image 109
oieduardorabelo Avatar answered Oct 25 '25 23:10

oieduardorabelo


For Ubanntu users

use

sudo npm i -g serverless
like image 21
hariom nagar Avatar answered Oct 25 '25 23:10

hariom nagar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!