npm install 卡在“sill IdealTree buildDeps”上 [如何解决]

18,756 阅读3分钟

npm install出现“sill IdealTree buildDeps”挂起的问题有多种原因:

  1. 未正确配置 NPM 注册表(registry)
  2. 有故障的node_modules目录或package-lock.json文件
  3. 缓存问题
  4. 使用 VPN 或互联网连接速度非常慢
  5. 混用 NPM 和 YARN 命令

重新配置注册表

npm cache clear --force
npm config set registry http://registry.npmjs.org/

之后尝试重新运行npm install命令。

设置正确之后,NPM 连接到注册表 会按名称和版本解析包。如果您的注册表设置不正确,则 npm install 命令会可能会卡住并显示“sill IdealTree buildDeps”消息。

删除你的node_modules并重新安装你的依赖项

node_modules文件夹和 package-lock.jsonyarn.lock 文件出现故障,也会出现此问题。

windows 和 macos 下具体操作:

# for Windows
rd /s /q "node_modules"
del package-lock.json
del -f yarn.lock

# 👇️ clean npm cache
npm cache clean --force

npm install
# for macOS or Linux
rm -rf node_modules
rm -f package-lock.json
rm -f yarn.lock

# 👇️ clean npm cache
npm cache clean --force

npm install

如果在 IDE 中使用集成终端并且问题仍然存在, 可以重新启动代码编辑器试试

尝试禁用该strict-ssl设置

经过以上操作账户问题仍然存在,可以尝试 禁用 strict-ssl 密钥验证。

npm config set registry http://registry.npmjs.org/

npm config set strict-ssl false

设置strict-sslfalse在通过 HTTPS 向 NPM 注册表发出请求时禁用 SSL 验证。

如果要启用strict-ssl,请将其设置回true

尝试关闭 VPN 并重新运行 npm install

连接问题的另一个原因是使用 VPN。

如果您使用 VPN,请尝试禁用它并重新运行该npm install命令。

您还可以尝试重新启动 Wifi 连接。

重新连接到同一网络或使用不同的网络通常会有所帮助。

确保不要混合使用 NPM 和 YARN 命令

当您有时使用 NPM、有时使用 YARN 时,也会出现此问题。

yarn install如果遇到困难,请尝试使用该命令npm install

还可以删除node_modulespackage-lock.jsonyarn.lock 文件并重新运行该yarn install命令。

建议正常情况下不要将两者混合使用。

解决 macOS 上的问题

如果您使用的是带有M1芯片的 macOS:

  1. 转至系统设置
  2. 单击侧栏中的网络。
  3. 点击无线网络。
  4. 单击已连接的网络并选择详细信息。
  5. 单击TCP/IP并选择将 IPv6 从“自动”更改为“仅链接本地”

如果您使用的是带有M2芯片的 macOS:

  1. 转至系统设置
  2. 单击侧栏中的网络。
  3. 点击无线网络。
  4. 单击已连接的网络并选择详细信息。
  5. 单击 “TCP/IP” 并选择 “配置 IPv6”,从“自动”更改为“仅链路本地”

进行更改后,重新运行该npm install命令。

 更新你的 NPM 版本

如果问题仍然存在,请尝试更新npm版本(npm如果您能够连接到存储库)。

npm install -g npm@latest

如果您在 Linux 或 macOS 上遇到权限错误,请重新运行前缀为sudo.

sudo npm install -g npm@latest

如果您在 Windows 上遇到权限错误,请以管理员身份打开 CMD 并重新运行该命令。