【问题标题】:Error installing sharp with npm on macOS在 macOS 上使用 npm 安装Sharp时出错
【发布时间】:2018-03-02 00:00:10
【问题描述】:

如果我创建一个新的 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 运行也无济于事。

关于如何追踪问题所在有什么想法吗?

【问题讨论】:

    标签: npm sharp


    【解决方案1】:

    我发现sharp 缺少全局依赖项。

    如果你运行

    npm install -g node-gyp
    

    ,然后

    npm install --save sharp
    

    有效。

    【讨论】:

      猜你喜欢
      • 2020-11-15
      • 2020-02-11
      • 1970-01-01
      • 2016-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      • 2014-10-29
      相关资源
      最近更新 更多