node.js

关注公众号 jb51net

关闭
首页 > 网络编程 > JavaScript > node.js > npm install报错ERR code ETIMEDOUT

关于npm install报错ERR code ETIMEDOUT的问题及解决

作者:前端 贾公子

这篇文章主要介绍了关于npm install报错ERR code ETIMEDOUT的问题及解决,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教

npm install报错ERR code ETIMEDOUT

//1.查看npm镜像设置
npm config get registry
//2.将npm设置为淘宝镜像
npm config set registry https://registry.npm.taobao.org
//3.再次查看npm镜像设置
npm config get registry
//4.重新install
npm install

要查看npm源,可以使用以下命令:

1. 查看当前的npm源

   npm config get registry

2. 查看所有可用的npm源

   npm config ls -l

3. 切换npm源

   npm config set registry 

其中,``是你要切换的npm源的URL。

例如,要查看当前的npm源,可以运行以下命令:

npm config get registry

输出类似于`https://registry.npmjs.org/`的URL,表示当前的npm源是官方的npm源。

要查看所有可用的npm源,可以运行以下命令:

npm config ls -l

这会列出所有的npm配置,包括当前的npm源。

要切换npm源,可以运行以下命令:

npm config set registry 

例如,要切换到淘宝的npm源,可以运行以下命令:

npm config set registry https://registry.npm.taobao.org/

npm安装报错 npm ERR! request to https://registry.npm.taobao.org/ failed, reason: certificate has expired

错误原因:

解决方案:

// 1. 清空缓存
npm cache clean --force
// 2. 切换新源
npm config set registry https://registry.npmmirror.com
// 3. 查看源是否设置成功
npm config get registry
// 4. 可以正常安装需要的工具了
npm insatll xxx
)

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文