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

Created on 18 Sep 2018  路  5Comments  路  Source: nodejs/node-gyp

  • 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 
ERR! node-gyp -v <= v5.1.0

Most helpful comment

Try using the sudo chmod 777command 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

All 5 comments

Try using the sudo chmod 777command 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

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.

Try using the sudo chmod 777command 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

Hi,

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

Best regards,
Zhitomir

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

Was this page helpful?
0 / 5 - 0 ratings