首页 > 解决方案 > M1 Big Sur 的 npm install 出现急剧返回错误

问题描述

我正在尝试为我的项目安装Sharp。运行 npm i 和 npm install sharp 时,我收到关于 sharp 相同的错误(如下所示)。我尝试在全局和本地安装 libvip,并阅读了有关此问题的每个线程,但似乎找不到正确的解决方案。欢迎任何建议。

rosetta error: /var/db/oah/223263137464320_223263137464320/e6ddd63cd8fd3b7ef226e2cad9a1bead9d7f41f60d7ece6edd0cdcc0c33c97c6/libxcrun.dylib.aot: attachment of code signature supplement failed: 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: null
gyp ERR! stack     at ChildProcess.onExit (/Users/elektra.murphy/.nvm/versions/node/v11.11.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:197:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:254:12)
gyp ERR! System Darwin 20.6.0
gyp ERR! command "/Users/elektra.murphy/.nvm/versions/node/v11.11.0/bin/node" "/Users/elektra.murphy/.nvm/versions/node/v11.11.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/elektra.murphy/Desktop/Projects/node_modules/sharp
gyp ERR! node -v v11.11.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/Users/elektra.murphy/Desktop/Projects/package.json'
npm WARN No description
npm WARN No repository field.
npm WARN No README data
npm WARN No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.23.2 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sharp@0.23.2 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/elektra.murphy/.npm/_logs/2021-10-12T08_24_48_579Z-debug.log

标签: npmgulphomebrewsharp

解决方案


在 Sharp 文档中找到了解决方案:使用 npm v6 或更早版本时,在以 root 或 sudo 用户身份安装时必须使用 npm install --unsafe-perm 标志。似乎奏效了——现在开始下一个错误!

在此处查找有关 M1 安装的更多信息:

https://sharp.pixelplumbing.com/install


推荐阅读