node.bcrypt.js icon indicating copy to clipboard operation
node.bcrypt.js copied to clipboard

node-gyp: Permission denied

Open mark-hahn opened this issue 13 years ago • 15 comments

I can't install the latest, 0.7.5, on my ubuntu server. This is giving me strong deja vu. I think I've seen this on other modules and maybe on bcrypt before. I don't remember how I got past it. Maybe the problem has to do with installing while logged in as root? Here is the error:

$ npm install bcrypt
npm http GET https://registry.npmjs.org/bcrypt
npm http 304 https://registry.npmjs.org/bcrypt
npm http GET https://registry.npmjs.org/bindings/1.0.0
npm http 304 https://registry.npmjs.org/bindings/1.0.0

> [email protected] install /ri/node_modules/bcrypt
> node-gyp rebuild

sh: 1: node-gyp: Permission denied
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! `sh "-c" "node-gyp rebuild"` failed with 127
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the bcrypt package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.2.0-31-virtual
npm ERR! command "/root/.nvm/v0.10.0/bin/node" "/root/.nvm/v0.10.0/bin/npm" "install" "bcrypt"
npm ERR! cwd /ri
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /ri/npm-debug.log
npm ERR! not ok code 0

mark-hahn avatar Mar 20 '13 21:03 mark-hahn

You have permission problems. Fix them.

defunctzombie avatar Mar 20 '13 21:03 defunctzombie

It appears that node and npm were installed under root and into a directory controlled by root. Normally the bash prompt for non root is $. Since that is what appears in your output I'd guess that you're using the wrong user to install the module. But, as @shtylman noted, this is definitely environmental.

ncb000gt avatar Mar 22 '13 02:03 ncb000gt

Thanks. I've always run as root and therefore thought it was impossible to have permission problems. I don't even know what gyp is so I'm going to have a bit of a problem figuring out where the permission problem is.

On Thu, Mar 21, 2013 at 7:19 PM, Nick Campbell [email protected]:

It appears that node and npm were installed under root and into a directory controlled by root. Normally the bash prompt for non root is $. Since that is what appears in your output I'd guess that you're using the wrong user to install the module. But, as @shtylmanhttps://github.com/shtylmannoted, this is definitely environmental.

— Reply to this email directly or view it on GitHubhttps://github.com/ncb000gt/node.bcrypt.js/issues/153#issuecomment-15277731 .

mark-hahn avatar Mar 22 '13 02:03 mark-hahn

So, after a little digging on the tubes I came across https://github.com/isaacs/npm/issues/294.

I'm guessing that you'll need to use npm install bcrypt --unsafe-perms

ncb000gt avatar Mar 22 '13 02:03 ncb000gt

Thanks you very much. I gave it a quick try and still had the problem but you've given me a head start on figuring this out. I'm a real noob when it comes to permissions but this will be a good forced lesson.

On Thu, Mar 21, 2013 at 7:57 PM, Nick Campbell [email protected]:

So, after a little digging on the tubes I came across isaacs/npm#294https://github.com/isaacs/npm/issues/294 .

I'm guessing that you'll need to use npm install bcrypt --unsafe-perms

— Reply to this email directly or view it on GitHubhttps://github.com/ncb000gt/node.bcrypt.js/issues/153#issuecomment-15278667 .

mark-hahn avatar Mar 22 '13 04:03 mark-hahn

BTW, I put the prompt $ in my sample output but I just did that to remove the long prompt that was there. I'm always logged in as root. I do sudo -i every time I start a session. I've used unix/linux on and off for 35 years (not a typo) and I've never logged in as anything but root. I know it is supposed to be dangerous but I've never understood why. I've never typed rm -rf / and I don't plan to.

mark-hahn avatar Mar 22 '13 05:03 mark-hahn

This helped me: http://stackoverflow.com/questions/2009278/python-multiprocessing-permission-denied

sarme avatar Mar 16 '14 02:03 sarme

This solves the issue: https://github.com/jansmolders86/mediacenterjs/issues/191#issuecomment-101188637

denics avatar Oct 12 '15 12:10 denics

Adding a non-root user and installing node there helped me.

MaartenW avatar May 24 '17 19:05 MaartenW

This is quite dummy solution, but in my case, after trying all of your suggestions out, only deleting node v8.4.0 and installing v9.2.0 (all done as non-root) helped. I have to admit, that I have no clue about the reason of this issue.

Cajivah avatar Nov 28 '17 19:11 Cajivah

Hi all, following this commend working fine...:) #npm install -g node-gyp node-pre-gyp or $sudo npm install -g node-gyp node-pre-gyp

isathish avatar Dec 13 '17 12:12 isathish

npm install --unsafe-perm

AnechaS avatar Jun 20 '19 11:06 AnechaS

npm install --unsafe-perm

Thanks bro!!! It worked

macin40 avatar May 18 '20 08:05 macin40

npm install --unsafe-perm

Great worked thanks :)

gvsakhil avatar Jul 22 '20 14:07 gvsakhil

Hi all, following this commend working fine...:) #npm install -g node-gyp node-pre-gyp or $sudo npm install -g node-gyp node-pre-gyp

thank you you saved a few hours of scratching my head i just installed npm install -g node-gyp node-pre-gyp and and it fixed my the problem i was having with installing bcrypt

belly34 avatar Oct 19 '23 03:10 belly34