'After setting npm config proxy ubuntu, npm not working
Npm crashed after running these two commands:
$ npm config set proxy http://login:pass@host:port
$ npm config set https-proxy http://login:pass@host:port
When I enter another command such as npm install
or npm build
my Terminal shows this error:
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)
Solution 1:[1]
I had the same error on running npm install
.
The problem was in the proxy password in the .npmrc
file. It contained the %
symbol.
All special symbols have to be URL-encoded. See issue #7353.
When I had changed %
to %25
it started working fine.
Solution 2:[2]
Try this (works in linux)
To set the proxy run:
npm config set proxy http://username:password@host:port
To unset the proxy run:
npm config set proxy null
To Check if the proxy is set run:
npm config get proxy
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | RobC |
Solution 2 | RobC |