在终端上写入 npm install learnyounode -g 时?12.04 LTS

在终端上写入 npm install learnyounode -g 时?12.04 LTS
~$ npm install learnyounode -g

npm ERR! registry error parsing json

npm ERR! SyntaxError: Unexpected token <

npm ERR! <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><meta http-equiv="content-type"content="text/html;charset=utf-8"/><title></title><script type="text/javascript">StaticRequestInfo={Referer:document.referrer};function EscapeBrowserFrame(){try{if(window.top.location==window.self.location){}else{window.top.location.href=document.location.href}}catch(Error){}}function SetRequestTitle(){document.title=document.domain}function InitiateFrameRequest(){var url = "/?acc=0F4B1727-114A-4EF2-AC1B-1DB964D84818&ref=install+learnyounode&framerequest=1&pcc=";document.write("<frameset rows=\"100%,*\" frameborder=\"no\" border=\"0\" framespacing=\"0\"><frame src=\""+url+"\" name=\"landingparent\" id=\"landingparent\">
<\/frameset>")}SetRequestTitle();EscapeBrowserFrame();</script></head><script type="text/javascript">InitiateFrameRequest();</script><body><noscript><meta http-equiv="refresh" content="0;url=/?acc=0F4B1727-114A-4EF2-AC1B-1DB964D84818&ref=install+learnyounode&framerequest=1&noscript=1&pcc="></noscript><noframes><meta http-equiv="refresh" content="0;url=/?acc=0F4B1727-114A-4EF2-AC1B-1DB964D84818&ref=install+learnyounode&framerequest=1&noscript=1&pcc="></noframes></body></html>
npm ERR!     at Object.parse (native)
npm ERR!     at RegClient.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:274:23)
npm ERR!     at /usr/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:251:7
npm ERR!     at Gunzip.onEnd (zlib.js:167:5)

npm ERR!     at Gunzip.emit (events.js:117:20)

npm ERR!     at _stream_readable.js:944:16

npm ERR!     at process._tickCallback (node.js:448:13)

npm ERR! If you need help, you may report this *entire* log,

npm ERR! including the npm and node versions, at:

npm ERR!     <http://github.com/npm/npm/issues>


npm ERR! System Linux 3.8.0-44-generic

npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "learnyounode" "-g"

npm ERR! cwd /home/hypertext

npm ERR! node -v v0.10.37

npm ERR! npm -v 1.4.28

npm ERR! type unexpected_token

npm ERR! 

npm ERR! Additional logging details can be found in:
npm ERR!     /home/hypertext/npm-debug.log
npm ERR! not ok code 0

======================================================================= hypertext@hypertext-desktop:~$ npm config set proxy http: hypertext@hypertext-desktop:~$ npm config get proxy npm WARN invalid config proxy="http:" npm WARN invalid config 必须是带有“http://”的完整 url null hypertext@hypertext-desktop:~$ npm config get https-proxy npm WARN invalid config proxy="http:" npm WARN invalid config 必须是带有“http://”的完整 url null hypertext@hypertext-desktop:~$

答案1

这是一个与 SSL 证书相关的问题,最常见的情况是尝试npm通过代理运行。有几种方法可以解决这个问题:

  • 你可以重置 npm 的代理设置通过运行:

    • npm config rm proxy
    • npm config rm https-proxy
  • 您可以使用非 https 版本的 npm:

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

相关内容