我尝试创建一个新的 NodeJs 项目,当我运行“npm init”时,package.json 已成功创建,但是当我尝试运行“npm install express”时,它显示“npm ERR!代码 ERR_OUT_OF_RANGE”。如果没有出现此错误,我将无法运行 npm install。
我尝试安装其他包,我尝试了 sudo,我删除了 npm/node 并重新安装了 nvm/node 但它仍然是一样的。
感谢您的帮助!
npm install express
npm ERR! code ERR_OUT_OF_RANGE
npm ERR! The value of "err" is out of range. It must be a negative integer. Received 536870212
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/me/.npm/_logs/2019-09-18T14_49_07_222Z-debug.log
最佳答案
问题是您的 Node 和 NPM 版本不匹配。 当更新一个而没有更新另一个时,可能会发生这种情况。
要防止这些问题,请使用 nvm管理您的 Node 版本:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.1/install.sh | bash
# Example: Selecting Node v13
# For complete list of available versions run `nvm ls-remote`
nvm install 13
nvm use 13
这将选择匹配的 Node 和 NPM 版本。
关于node.js - 使用 npm install 时报错 "ERR_OUT_OF_RANGE",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57995646/