node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'

Open MJOAN opened this issue 8 years ago • 11 comments

  • Node Version: node version 9.8.0 (8.11.1) and npm version 5.6.0
  • Platform Linux 4.9.76-xx.xx.amzn2.x86_64, MacBook Pro 10.13.6
  • Compiler: Terminal (SSH'd into EC2 Linux instance when compiling)
  • Module: node-gyp 3.8.0

Received Slack message regarding error with node_modules/fibers/bin/linux-x64-59/fibers' and recommendation to run a script. I ran the fibers/build script but, then received notification must install node-gyp. (Note* I see the rmdir 'build' in the error however, the command from the initial error told me to run the path including /build). To confirm the path we want for npm and node-gyp is: /opt/node/bin/ -- when ls -al I see npm and node-gyp are there.

Then the following error received after installing node-gyp:

[[email protected] /]$  /opt/node/bin/node /opt/something/server/node_modules/fibers/build
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp ERR! clean error 
gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
gyp ERR! System Linux 4.9.76-xx.xx.amzn2.x86_64
gyp ERR! command "/opt/node/bin/node" "/opt/node/bin/node-gyp" "rebuild" "--release"
gyp ERR! cwd /
gyp ERR! node -v v9.8.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

Then received following after running command node-gyp rebuild:

[email protected]  /opt/node/lib/node_modules/node-gyp
[email protected]
[[email protected] /]$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp ERR! clean error 
gyp ERR! stack Error: EACCES: permission denied, rmdir 'build'
gyp ERR! System Linux 4.9.76-xx.xx.amzn2.x86_64
gyp ERR! command "/opt/node/bin/node" "/opt/node/bin/node-gyp" "rebuild"
gyp ERR! cwd /
gyp ERR! node -v v9.8.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

MJOAN avatar Sep 18 '18 18:09 MJOAN

Try using the sudo chmod 777 command for the node_modules directory and if that doesn't work try sudo npm install -g --unsafe-perm or sudo node-gyp rebuild -g --unsafe-perm

Mentors4EDU avatar Oct 09 '18 20:10 Mentors4EDU

You probably mixed permissions at one point. rmdir build manually (I'm betting it's owned by root) and run rebuild again. node-gyp will recreate it with the right permissions.

bnoordhuis avatar Nov 09 '18 19:11 bnoordhuis

Try using the sudo chmod 777 command for the node_modules directory and if that doesn't work try sudo npm install -g --unsafe-perm or sudo node-gyp rebuild -g --unsafe-perm

The second line worked for me, thanks a lot

esmejia277 avatar Apr 26 '19 17:04 esmejia277

Hi,

From above comment following command worked for me: sudo npm install --unsafe-perm

Best regards, Zhitomir

zhnedyalkow avatar Sep 11 '19 07:09 zhnedyalkow

Try with this one! sudo npm install -g cordova-res --unsafe-perm flag

nickkcuevas avatar May 11 '20 04:05 nickkcuevas

This no longer works as of NPM 7 (packaged wit Node 15) as the --unsafe-perm flag has been removed: https://github.com/npm/cli/pull/2196

andrewzey avatar Feb 12 '21 16:02 andrewzey

Perhaps find or open an issue at https://github.com/ionic-team/cordova-res

cclauss avatar Feb 12 '21 18:02 cclauss

I had to run the permission change recursively on the directory of the package I was trying to rebuild sudo chmod -R 777

quinton-ashley avatar Feb 13 '21 07:02 quinton-ashley

Upgrading to NPM 7+ solved the problem for me

bilal-korir avatar Feb 22 '21 03:02 bilal-korir

do you mean sudo npm install -g --unsafe-perm node-gyp

Try using the sudo chmod 777 command for the node_modules directory and if that doesn't work try sudo npm install -g --unsafe-perm node-gyp or sudo node-gyp rebuild -g --unsafe-perm

davidpharrington avatar Aug 19 '21 07:08 davidpharrington

https://github.com/nodejs/node-gyp/blob/master/docs/Updating-npm-bundled-node-gyp.md

cclauss avatar Aug 19 '21 07:08 cclauss