设置npm config代理ubuntu后,npm无法正常工作

时间:2018-10-12 10:22:13

标签: node.js npm ubuntu-16.04

执行以下两个命令后: $ npm config set proxy http://login:pass@host:port

$ npm config set https-proxy http://login:pass@host:port

Npm崩溃了。当我输入另一个命令,例如npm install或npm build。

显示此内容的终端

URIError: URI malformed
    at decodeURIComponent (native)
    at Url.parse (url.js:195:19)
    at Object.urlParse [as parse] (url.js:84:5)
    at Object.validateUrl [as validate] (/usr/share/npm/node_modules/nopt/lib/nopt.js:164:13)
    at validate (/usr/share/npm/node_modules/nopt/lib/nopt.js:212:24)
    at validate (/usr/share/npm/node_modules/nopt/lib/nopt.js:179:11)
    at /usr/share/npm/node_modules/nopt/lib/nopt.js:101:12
    at Array.map (native)
    at /usr/share/npm/node_modules/nopt/lib/nopt.js:67:15
    at Array.forEach (native)

/usr/share/npm/lib/npm.js:34
      throw new Error('npm.load() required')
      ^

Error: npm.load() required
    at Object.npm.config.get (/usr/share/npm/lib/npm.js:34:13)
    at exit (/usr/share/npm/lib/utils/error-handler.js:60:40)
    at process.errorHandler (/usr/share/npm/lib/utils/error-handler.js:178:3)
    at emitOne (events.js:77:13)
    at process.emit (events.js:169:7)
    at process._fatalException (node.js:223:26)

1 个答案:

答案 0 :(得分:0)

尝试一下(在Linux中有效)

use Auth;


# To set proxy
npm config set proxy http://username:password@host:port


# To unset proxy
npm config set proxy null