在Mac M1上安装npm时遇到问题

vsnjm48y  于 2022-12-13  发布在  Mac
关注(0)|答案(6)|浏览(293)
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 
npm WARN deprecated bcrypt@4.0.1: versions < v5.0.0 do not handle NUL in passwords properly
npm ERR! code 1
npm ERR! path /Users/nikhil/Desktop/admin/myprivatescout-master/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@16.6.1.
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/nikhil/.npm/_logs/2021-08-23T17_20_39_011Z-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/nikhil/Desktop/admin/myprivatescout-master/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:100:19)
npm ERR!     at ChildProcess.<anonymous> (/Users/nikhil/Desktop/admin/myprivatescout-master/node_modules/node-bin-setup/index.js:18:27)
npm ERR!     at ChildProcess.emit (node:events:394:28)
npm ERR!     at maybeClose (node:internal/child_process:1067:16)
npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5) {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: [
npm ERR!     '/Users/nikhil/Desktop/admin/myprivatescout-master/node_modules/node/installArchSpecificPackage.js'
npm ERR!   ]
npm ERR! }

npm ERR! A complete log of this run can be found in:

npm ERR!     /Users/nikhil/.npm/_logs/2021-08-23T17_20_39_074Z-debug.log

我无法在我的mac M1上安装我的项目库中的任何包,已经删除了node_modules和package-lock.json,并在那之后尝试了npm i。
尝试运行npm i,npm i为个别软件包,但无法修复它,也尝试安装与Yarn,但我面临着同样的问题。

mqxuamgl

mqxuamgl1#

将体系结构添加到节点:

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

cedebl8k2#

Nikhil提供的解决方案是一个很好的开始,然而,这更完整,适用于更多的情况:
首先,安装nvm(节点版本管理器):

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

然后,运行以下命令:

arch -x86_64 zsh
cnh2zyt3

cnh2zyt33#

我们对这个问题进行了开发,一台M1笔记本电脑在2021年12月买了新的。ralphjsmit的解决方案让我们走上了一部分道路。
我们使用的是Nodejs v16.13.1。运行arch -x86_64 zsh后,npm安装仍然失败(Error: Cannot find module 'node-darwin-arm64/package.json')。
arch返回了i386
我们的关键是重新安装Nodejs(通过nvm,nvm use v16.5.0 && nvm uninstall v16.13.1 && nvm install v16.13.1
如果要我总结我们执行的所有步骤,它们将是

> node -v
v16.13.1
> node -p process.arch
arm64
> arch -x86_64 zsh
> nvm use 16.5.0 && nvm uninstall v16.13.1 && nvm install v16.13.1
nvm use 16.5.0 && nvm uninstall v16.13.1 && nvm install v16.13.1
Now using node v16.5.0 (npm v7.19.1)
Uninstalled node v16.13.1
Downloading and installing node v16.13.1...
... 
# output here, I am not on an M1 machine, but it mentions x64 in the name of the node binary file
...
Now using node v16.13.1 (npm v8.1.2)
> npm install
nfs0ujit

nfs0ujit4#

重新安装旧版本的NodeJS(& NPM)似乎对我有帮助。请尝试here中的14.18.3版本。

e3bfsja2

e3bfsja25#

确保您没有package.json中指定节点版本。

nbewdwxp

nbewdwxp6#

arch -arm64 npm i对我起作用了!

相关问题