node.js - 安装 grunt 时出现 NodeJS NPM 代理错误

标签 node.js proxy gruntjs npm

当我尝试通过 npm 安装 grunt 时,出现以下错误:

C:\Program Files\nodejs\node_modules\npm>npm install -g grunt
npm ERR! network connect ETIMEDOUT
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is 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! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "grunt"
npm ERR! cwd C:\Program Files\nodejs\node_modules\npm
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Program Files\nodejs\node_modules\npm\npm-debug.log
npm ERR! not ok code 0

我正在使用企业代理配置,并且我认为我遇到此错误是因为它的配置。为了成功安装 grunt,我需要进行哪些更改?

最佳答案

您需要配置 npm 配置文件,这可以在终端中完成:

npm config set proxy http://proxy.company.com:8080

npm config set https-proxy http://proxy.company.com:8080

您的错误日志建议查看“npm help config”,所以我认为问题来自那里。

如果您需要更多解释的链接,请参阅 this blog entry (还有很多)

祝你好运!

关于node.js - 安装 grunt 时出现 NodeJS NPM 代理错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26989401/

相关文章:

javascript - 找不到任务和子任务

生产服务器上的node.js

node.js - Docker 与 Node bcrypt — 无效的 ELF header

java - Camel代理动态url参数设置

java - 在基于 Java 的 Web 服务中使用代理获取网页

python - Mitmproxy使用python加载和卸载脚本

javascript - 在 Node.js 中使用 require() 函数有哪些不同的方式?

node.js - Mongoose : custom schema type

javascript - Grunt Globbing 模式

javascript - 将 grunt 添加到基于 AngularJS 构建的现有应用程序