首页 > 解决方案 > NPM,从错误的 URL 地址下载依赖项

问题描述

在处理了一些项目之后,我的 npm 开始从错误的地址全局下载依赖项:

npm install -g bower

npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to http://172.168.1.1/bower failed, reason: 
    connect ETIMEDOUT 172.168.1.1
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

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

有什么方法可以将下载地址重置为默认地址吗?

我正在使用 Windows 版本的 NodeJS

标签: node.jsnpm

解决方案


看起来您的registrynpm 配置选项指向错误的位置。它必须是https://registry.npmjs.org,使用以下命令进行检查:

npm config get registry

如果您的注册表不同,请使用此命令正确设置:

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

推荐阅读