NPM安装“在M1芯片上找不到模块'node-darwin-arm64/package.json'”

10

我知道已经有不同版本的这个问题被问过了,但是我还没有看到不需要安装rosetta或者用zsh来假装架构的解决方案。我使用bash,希望尽可能避免处理Rosetta。

我是一个node新手,正在努力弄清楚是什么导致失败。

Node - v16.14.0

NPM - 8.3.1

Yarn - 1.22.17

我用npm或yarn得到相同的错误。

任何建议都将不胜感激。谢谢。

npm ERR! code 1
npm ERR! path /Users/joefedorowicz/Development/xwingui/react-ui/node_modules/node
npm ERR! command failed
npm ERR! command sh -c node installArchSpecificPackage
npm ERR! npm ERR! code ETARGET
npm ERR! npm ERR! notarget No matching version found for node-darwin-arm64@12.22.6.
npm ERR! npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! npm ERR! notarget a package version that doesn't exist.
npm ERR! 
npm ERR! npm ERR! A complete log of this run can be found in:
npm ERR! npm ERR!     /Users/joefedorowicz/.npm/_logs/2022-02-16T15_52_10_981Z-debug.log
npm ERR! node:internal/modules/cjs/loader:936
npm ERR!   throw err;
npm ERR!   ^
npm ERR! 
npm ERR! Error: Cannot find module 'node-darwin-arm64/package.json'
npm ERR! Require stack:
npm ERR! - /Users/joefedorowicz/Development/xwingui/react-ui/node_modules/node/installArchSpecificPackage.js
npm ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
npm ERR!     at Function.resolve (node:internal/modules/cjs/helpers:108:19)
npm ERR!     at ChildProcess.<anonymous> (/Users/joefedorowicz/Development/xwingui/react-ui/node_modules/node-bin-setup/index.js:18:27)
npm ERR!     at ChildProcess.emit (node:events:520:28)
npm ERR!     at maybeClose (node:internal/child_process:1092:16)
npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5) {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: [
npm ERR!     '/Users/joefedorowicz/Development/xwingui/react-ui/node_modules/node/installArchSpecificPackage.js'
npm ERR!   ]
npm ERR! }
1个回答

19

使用此架构标志重新安装node对我有用:

$ nvm uninstall 14
$ arch -x86_64 zsh 
$ nvm install 14
$ nvm alias default 14

根据这篇文章。

3
这个解决方案对我也起作用了。我有一台Mac M1 Pro,在运行yarn install时遇到了同样的问题。 - Eric Guzman

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接