Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

NPM Error: gyp ERR! stack Error: EACCES: permission denied

npm install [Tried using root]
sudo npm install [Tried using ubuntu]

Error

gyp verb build dir attempting to create "build" dir: /opt/lampp/htdocs/surgery-planet-repo/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/opt/lampp/htdocs/surgery-planet-repo/node_modules/node-sass/build'
gyp ERR! System Linux 4.15.0-1044-aws
gyp ERR! command "/usr/bin/node" "/opt/lampp/htdocs/surgery-planet-repo/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /opt/lampp/htdocs/surgery-planet-repo/node_modules/node-sass
gyp ERR! node -v v13.6.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN ajv-keywords@3.4.1 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.13.1 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!     /home/ubuntu/.npm/_logs/2020-01-21T06_46_52_290Z-debug.log

Solutions

First Solution 1

$ sudo npm i –unsafe-perm

Last Solution 2
$ sudo rm -rf ~/.node-gyp
$ sudo npm cache clean -f
$ sudo npm install -g n
$ sudo n stable
$ sudo npm i -unsafe-perm

Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)