Npm 在安装 @angular2-material 包时抛出 'must have a URL that starts with http: or https:'

Npm throws 'must have a URL that starts with http: or https:' when installing @angular2-material packages

我正在使用 npm 安装 @angular2-material/core(或任何其他模块),但不允许我安装任何模块。

npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "@angular2-material/core"
npm ERR! node v5.11.1
npm ERR! npm  v3.8.6

npm ERR! must have a URL that starts with http: or https:
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

我试过了:

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

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

但这行不通,我向 material 人提出了这个问题,但他们说这是我的本地问题。

这真让我难受,根本不知道如何解决它。

https://github.com/angular/material2/issues/720

这主要是因为您尝试了多个注册表,现在 npm 有点混乱,您需要打开 .npmrc 并删除不必要的注册表路径。

找到你的 .npmrc :

     npm config ls -l | grep config

您会看到类似这样的内容:

     userconfig /Users/Yourname/.npmrc      

然后用您的编辑器打开该文件,编辑并删除多余的不必要注册表。