2

如果我创建一个新的 npm 项目:

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

然后尝试安装sharp

npm install --save sharp

我收到以下错误消息:

> 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

我找到了删除的说明~/.node-gyp,试过了,没有用。删除node_modules再试也行不通。运行sudo也无济于事。

关于如何追踪问题所在的任何想法?

4

1 回答 1

5

我发现缺少sharp.

如果你跑

npm install -g node-gyp

首先,然后

npm install --save sharp

有用。

于 2017-09-20T19:24:50.713 回答