角度2的npm包安装错误

时间:2016-04-20 08:12:45

标签: npm angular npm-install

我在公司代理防火墙后面,每当我在命令提示符下输入npm install命令时,我都会收到此错误。以前它会让我编辑具有代理设置的npm文件,现在我收到此错误,无论我输入什么npm命令:

URIError: URI malformed
at decodeURIComponent <native>    
at Url.parse <url.js:261:19>
at Object.urlParse [as parse] (url.js:67:5)
at Object.validateUrl [as validate] (C:\Program F
m\node_modules\nopt\lib\nopt.js:164:13)
 at validate (C:\Program Files\nodejs\node_modules
 nopt.js:213:24)
at validate (C:\Program Files\nodejs\node_modules
nopt.js:179:11)
at C:\Program Files\nodejs\node_modules\npm\node_
1:12
at Array.map (native)
at C:\Program Files\nodejs\node_modules\npm\node_
:15
at Array.forEach (native)

C:\Program Files\nodejs\node_modules\npm\lib\npm.js:3
  throw new Error('npm.load() required')
  ^

Error: npm.load() required
at Object.npm.config.get (C:\Program Files\nodejs
 s:37:13)
at exit (C:\Program Files\nodejs\node_modules\npm
:60:40)
at process.errorHandler (C:\Program Files\nodejs\
 error-handler.js:178:3)
at emitOne (events.js:90:13)
at process.emit (events.js:182:7)
at process._fatalException (node.js:236:26)

- 发现 -

发现它与c:\ users {username} .npmrc文件有关。从此文件中删除代理设置会使错误消失但我无法下载任何软件包。

- nprmc文件 -

;;;;
; npm userconfig file
; this is a simple ini-formatted file
; lines that start with semi-colons are comments.
; read `npm help config` for help on the various options
;;;;

proxy=http://192.168.240.192:8080/
registry=http://registry.npmjs.org/


;;;;
; all options with default values
;;;;
; access=null

; always-auth=false

; also=null

; bin-links=true

; browser=null

; ca=null

; cafile=undefined

; cache=C:\Users\test\AppData\Roaming\npm-cache

; cache-lock-stale=60000

; cache-lock-retries=10

; cache-lock-wait=10000

; cache-max=null

; cache-min=10

; cert=null

; color=true

; depth=null

; description=true

; dev=false

; dry-run=false

; editor=notepad.exe

; engine-strict=false

; force=false

; fetch-retries=2

; fetch-retry-factor=10

; fetch-retry-mintimeout=10000

; fetch-retry-maxtimeout=60000

; git=git

; git-tag-version=true

; global=false

; globalconfig=C:\Users\test\AppData\Roaming\npm\etc\npmrc

; global-style=false

; group=0

; heading=npm

; if-present=false

; ignore-scripts=false

; init-module=C:\Users\test\.npm-init.js

; init-author-name=

; init-author-email=

; init-author-url=

; init-version=1.0.0

; init-license=ISC

; json=false

; key=null

; legacy-bundling=false

; link=false

; local-address=undefined

; loglevel=warn

; long=false

; maxsockets=50

; message=%s

; node-version=5.10.1

; npat=false

; onload-script=null

; only=null

; optional=true

; parseable=false

; prefix=C:\Program Files\nodejs

; production=false

; progress=true

; proprietary-attribs=true

; proxy=null

; https-proxy=null

; user-agent=npm/{npm-version} node/{node-version} {platform} {arch}

; rebuild-bundle=true

; registry=https://registry.npmjs.org/

; rollback=true

; save=false

; save-bundle=false

; save-dev=false

; save-exact=false

; save-optional=false

; save-prefix=^

; scope=

; searchopts=

; searchexclude=null

; searchsort=name

; shell=C:\WINDOWS\system32\cmd.exe

; shrinkwrap=true

; sign-git-tag=false

; strict-ssl=true

; tag=latest

; tag-version-prefix=v

; tmp=C:\Users\test\AppData\Local\Temp

; unicode=false

; unsafe-perm=true

; usage=false

; user=0

; userconfig=C:\Users\test\.npmrc

; umask=0

; version=false

; versions=false

; viewer=browser

; _exit=true

; globalignorefile=C:\Users\test\AppData\Roaming\npm\etc\npmignore

1 个答案:

答案 0 :(得分:0)

发现它与c:\ usrs {username} .npmrc文件有关。从此文件中删除代理设置会使错误消失但我无法下载任何软件包。

避免完成所有这些步骤并使其在公司代理服务器之后工作的最佳方法是使用CNTLM作为用户KOL的回答:NPM behind NTLM proxy

相关问题