'darwin-arm64v8'二进制文件不能在'darwin-x64'平台上使用



我正在尝试使用我的Mac M1将功能部署到firebase,因此需要在node_modules/中安装npm install来安装软件包。我得到这个错误:

Error: 'darwin-arm64v8' binaries cannot be used on the 'darwin-x64' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'darwin-x64' platform.
at Object.hasVendoredLibvips (/Users/ali/Desktop/tajir/backend-mvp/appengine/back-end-flex/node_modules/sharp/lib/libvips.js:80:13)
at Object.<anonymous> (/Users/ali/Desktop/tajir/backend-mvp/appengine/back-end-flex/node_modules/sharp/lib/constructor.js:7:22)
at Module._compile (internal/modules/cjs/loader.js:1136:30)
at Module._compile (pkg/prelude/bootstrap.js:1394:32)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:10)
at Module.load (internal/modules/cjs/loader.js:984:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1024:19)
at Module.require (pkg/prelude/bootstrap.js:1338:31)
at require (internal/modules/cjs/helpers.js:72:18)

通常使用Mac M1的人都会遇到这个问题。Mac M1处理器为arm64。这里有一个解决方案,需要将终端架构更改为arch -x86_64 zsh,这是我不想做的。

所以,这就是我能够发现的解决方法(错误中也提到了一些步骤):

rm -rf node_modules/sharp
npm install --arch=x64 --platform=darwin sharp

对于我来说,我所要做的就是:

brew reinstall vips

然后重新安装。

我的答案与将函数部署到firebase无关,但我有完全相同的错误:

Error: 'darwin-x64' binaries cannot be used on the 'darwin-arm64v8' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'darwin-arm64v8' platform.

当我试图在mac M1上运行一个项目时,使用了一个不兼容的node版本。

当项目实际需要版本<=14时,我尝试使用版本16运行项目。

所以如果有人有这个问题可能值得检查节点版本

这对我有用

https://sharp.pixelplumbing.com/install

npm install --platform=darwin --arch=x64 sharp
npm rebuild --platform=darwin --arch=arm64 sharp

出于某种原因,我通过删除node_modules并重新安装它们来修复它。

Error: 'darwin-x64' binaries cannot be used on the 'darwin-arm64v8' platform. 
Please remove the 'node_modules/sharp' directory and run 'npm install' on the 
'darwin-arm64v8' platform.

我今天在本地运行盖茨比应用程序时遇到了这个错误。恢复到我在安装最初的Gatsby应用程序时使用的Node版本可以解决这个问题。从Node v16切换到v14.20

我有同样的问题发生在pod安装。不幸的是,上述答案都不起作用。为我修复这个问题的是用NPM重建sharp。

npm rebuild sharp

在MacOs上测试。这发生在你更新MacOs版本之后。尝试如下

nvm uninstall 14
nvm install 14
yarn

如果你得到错误nvm: Cannot uninstall currently-active node version。请尝试切换到另一个节点版本并卸载您想要的版本,然后返回到您想要使用的版本。

,

// Temporary switch to another version
nvm install 15
// Now you can uninstall version 14
nvm uninstall 14
// Reinstall version 14
nvm install 14
// Everything should work now.
yarn

相关内容

最新更新