3

If I create a fresh npm project:

mkdir ~/test
cd ~/test
npm init -y

And then try to install sharp:

npm install --save sharp

I get the following error messages:

> sharp@0.18.4 install /Users/hsribei/tmp/test/node_modules/sharp
> node-gyp rebuild

sh: /usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp: Permission denied
npm WARN test@1.0.0 No description
npm WARN test@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! sharp@0.18.4 install: `node-gyp rebuild`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the sharp@0.18.4 install 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!     /Users/hsribei/.npm/_logs/2017-09-20T19_11_03_836Z-debug.log

I've found instructions to delete ~/.node-gyp, tried that, didn't work. Deleting node_modules and trying again also doesn't work. Running as sudo doesn't help either.

Any ideas in how I can trace what the problem is?

agentofuser
  • 8,987
  • 11
  • 54
  • 85

1 Answers1

6

I found out there is a missing global dependency for sharp.

If you run

npm install -g node-gyp

first, then

npm install --save sharp

It works.

agentofuser
  • 8,987
  • 11
  • 54
  • 85