我正在使用 yeoman 构建我的角度应用程序。
我已按如下方式设置代理和注册表:
npm config set proxy http://proxy.tcs.com:8080
npm config set https-proxy http://proxy.tcs.com:8080
npm config set registry http://registry.npmjs.org/
即使像上面那样设置了代理之后,在安装的时候
npm install grunt-ngmin,
我得到以下错误,
npm WARN package.json teamshareangular@0.0.0 No README.md file found!
npm http GET http://registry.npmjs.org/grunt-ngmin
npm http 407 http://registry.npmjs.org/grunt-ngmin
npm ERR! registry error parsing json
npm ERR! SyntaxError: Unexpected token <
npm ERR! <HEAD><TITLE>Proxy Authorization Required</TITLE></HEAD>
npm ERR! <BODY BGCOLOR="white" FGCOLOR="black"><H1>Proxy Authorization Required</H1><HR>
npm ERR! <FONT FACE="Helvetica,Arial"><B>
npm ERR! Description: Authorization is required for access to this proxy</B></FONT>
npm ERR! <HR>
npm ERR! <!-- default "Proxy Authorization Required" response (407) -->
npm ERR! </BODY>
npm ERR!
npm ERR! at Object.parse (native)
npm ERR! at RegClient.<anonymous> (C:\Users\Documents\tools\nodejs\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:235:23)
npm ERR! at Request.self.callback (C:\Users\Documents\tools\nodejs\nodejs\node_modules\npm\node_modules\request\main.js:120:22)
npm ERR! at Request.EventEmitter.emit (events.js:98:17)
npm ERR! at Request.<anonymous> (C:\Users\Documents\tools\nodejs\nodejs\node_modules\npm\node_modules\request\main.js:648:16)
npm ERR! at Request.EventEmitter.emit (events.js:117:20)
npm ERR! at IncomingMessage.<anonymous> (C:\Users\Documents\tools\nodejs\nodejs\node_modules\npm\node_modules\request\main.js:610:14)
npm ERR! at IncomingMessage.EventEmitter.emit (events.js:117:20)
npm ERR! at _stream_readable.js:910:16
npm ERR! at process._tickCallback (node.js:415:13)
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:\\Users\\\Documents\\tools\\nodejs\\nodejs\\\\node.exe" "C:\\Users\\\Documents\\tools\\nodejs\\nodejs\\node_modules\\npm\\bin\\npm-cli.j
"grunt-ngmin"
npm ERR! cwd C:\nodejs\Teamshare\Teamshareangular
npm ERR! node -v v0.10.7
npm ERR! npm -v 1.2.14
npm ERR! type unexpected_token
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\nodejs\Teamshare\Teamshareangular\npm-debug.log
npm ERR! not ok code 0
为此要做什么?
我是否应该在 npm 中进行一些其他设置?
请指教。
最佳答案
您的代理需要身份验证。如果您在控制中有代理,则创建一个用户并使用以下命令配置 npm 以使用您的凭据。 (注意用户并在主机名前传递)
$ npm config set proxy http://login:pass@host:port
$ npm config set https-proxy http://login:pass@host:port
关于node.js - npm-yeoman 中的代理设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21178764/