【问题标题】:installing grunt using npm manager having connection issues使用 npm 管理器安装 grunt 时出现连接问题
【发布时间】:2016-02-08 16:41:40
【问题描述】:

嘿,我正在尝试使用 NPM 管理器安装 Grunt,但我似乎遇到了连接超时问题,我在网上搜索了一些。我可以点击这个 URL https://registry.npmjs.org/grunt 就好了,它会问我是否要保存或运行 GRUNT.JSON,如果我剪切并粘贴该 URL,我将在一个巨大的数组中看到该 JSON 的内容

GEL8953@VALGEL8953L MINGW64 ~/Dev/MillsDashboard/MillsDashboard (master)
$ npm install grunt grunt-cli -g
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/grunt
npm http GET https://registry.npmjs.org/grunt-cli
npm http GET https://registry.npmjs.org/grunt
npm http GET https://registry.npmjs.org/grunt-cli
npm ERR! Error: connect ETIMEDOUT
npm ERR!     at errnoException (net.js:901:11)
npm ERR!     at Object.afterConnect [as oncomplete] (net.js:892:19)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program      
Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "grunt"    
"grunt-cli" "-g"
npm ERR! cwd C:\Users\GEL8953\Dev\MillsDashboard\MillsDashboard
npm ERR! node -v v0.10.13
npm ERR! npm -v 1.3.2
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm

从项目根目录执行命令“npm i grunt”时,我得到以下信息

   GEL8953@VALGEL8953L MINGW64 ~/Dev/MillsDashboard/MillsDashboard (master)
   $ npm i grunt
   npm ERR! Error: Invalid name: "MillsDashbaord"
  npm ERR!     at ensureValidName (C:\Program Files     
  (x86)\nodejs\node_modules\npm\node_modu                                             
  les\read-package-json\node_modules\normalize-package-
  data\lib\fixer.js:281:15)
  npm ERR!     at Object.module.exports.fixNameField (C:\Program Files 
  (x86)\nodejs\node_mo                                             
  dules\npm\node_modules\read-package-json\node_modules\normalize-package-
  data\lib\fixer.js                                             :196:5)
  npm ERR!     at C:\Program Files 
  (x86)\nodejs\node_modules\npm\node_modules\read-package-                                             
  json\node_modules\normalize-package-data\lib\normalize.js:29:38
  npm ERR!     at Array.forEach (native)
  npm ERR!     at normalize (C:\Program Files 
  (x86)\nodejs\node_modules\npm\node_modules\re                                             
  ad-package-json\node_modules\normalize-package-  
  data\lib\normalize.js:28:15)
  npm ERR!     at final (C:\Program Files 
  (x86)\nodejs\node_modules\npm\node_modules\read-p                                             
  ackage-json\read-json.js:310:33)
  npm ERR!     at then (C:\Program Files 
  (x86)\nodejs\node_modules\npm\node_modules\read-pa                                             
  ckage-json\read-json.js:124:33)
  npm ERR!     at C:\Program Files 
  (x86)\nodejs\node_modules\npm\node_modules\read-package-                                             
  json\read-json.js:284:48
  npm ERR!     at fs.js:207:20
  npm ERR!     at Object.oncomplete (fs.js:107:15)
  npm ERR! If you need help, you may report this log at:
  npm ERR!     <http://github.com/isaacs/npm/issues>
  npm ERR! or email it to:
  npm ERR!     <npm-@googlegroups.com>

  npm ERR! System Windows_NT 6.1.7601
  npm ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "C:\\Program 
  Files (x86)\\no                                             
  dejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "grunt"
  npm ERR! cwd C:\Users\GEL8953\Dev\MillsDashboard\MillsDashboard
  npm ERR! node -v v0.10.13
  npm ERR! npm -v 1.3.2

【问题讨论】:

  • 你试过以su运行命令吗?
  • 不,我不知道该怎么做,因为我不熟悉 npm 管理器或其包
  • 你在用什么OS
  • 您的包名似乎无效。见stackoverflow.com/questions/18200814/…

标签: node.js gruntjs npm-install


【解决方案1】:

您可能需要设置注册表:

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

卸载并清理缓存:

npm uninstall -g grunt-cli

npm cache clean

npm i -g grunt-cli

Downcase 包含您的 bin 和控制器的 MillsDashboard。

npm i grunt

你在防火墙后面吗?代理?

【讨论】:

  • 我刚刚尝试了这个“npm i -g grunt-cli”并给出了同样的错误。我在“Dev/MillsDashboard/MillsDashboard”中,这是项目根目录,其中包含文件夹“bin、Content、Controllers、Models....etc..”也尝试了 npm i grunt 在同一目录中并说类似的错误不适编辑帖子到显示。
  • 已编辑 - 绝对将 MillsDashboard 与您的垃圾箱和控制器一起小写。不能有包含大写字母或数字的包。
  • 是防火墙问题。我通过手机的热点连接并正常访问。
猜你喜欢
  • 2015-01-15
  • 2018-12-05
  • 2012-09-02
  • 1970-01-01
  • 2016-07-30
  • 2018-06-03
  • 1970-01-01
  • 2013-05-06
  • 1970-01-01
相关资源
最近更新 更多