5

I have installed node.js But in command prompt npm command is not identified. I have set environmental variable also. Kindly help me out.

This is the response in command prompt:

C:\Users\593180.INDIA>npm
URIError: URI malformed
at decodeURIComponent (native)
at Url.parse (url.js:179:19)
at Object.urlParse [as parse] (url.js:101:5)
at Object.validateUrl [as validate] (C:\Program Files (x86)\nodejs\node_modu
les\npm\node_modules\nopt\lib\nopt.js:157:13)
at validate (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\nop
t\lib\nopt.js:205:24)
at validate (C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\nop
t\lib\nopt.js:172:11)
at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\nopt\lib\nopt
.js:101:12
at Array.map (native)
at C:\Program Files (x86)\nodejs\node_modules\npm\node_modules\nopt\lib\nopt
.js:67:15
at Array.forEach (native)
C:\Program Files (x86)\nodejs\node_modules\npm\lib\npm.js:37
throw new Error('npm.load() required')
      ^
Error: npm.load() required
at Object.npm.config.get (C:\Program Files (x86)\nodejs\node_modules\npm\lib
\npm.js:37:11)
at exit (C:\Program Files (x86)\nodejs\node_modules\npm\lib\utils\error-hand
ler.js:49:27)
at process.errorHandler (C:\Program Files (x86)\nodejs\node_modules\npm\lib\
utils\error-handler.js:314:3)
at process.EventEmitter.emit (events.js:95:17)
at process._fatalException (node.js:272:26)
2
  • The npm command is obviously found, but something seems terribly broken. I would try reinstalling. Commented Jun 11, 2014 at 14:15
  • Have you seen stackoverflow.com/questions/7300132/… Commented Jun 11, 2014 at 15:47

3 Answers 3

11

You probably broke npm by configuring your proxy or other URL

Go into your user folder

C:\Users\username

edit the file ".npmrc"

and fix your proxy url or other corrupted url proxy = http://login:password@proxyaddress:port

Sign up to request clarification or add additional context in comments.

4 Comments

Even after completely deleting the .npmrc file and uninstalling nodejs completely (even deleting manually the nodejs folder in program files),I still have this error
Looking up npmrc in the nodejs folder in the program files and deleting all of them fixed it for me
Why down vote ? I encountered this issue and my answer solved it. Ofc it's not magic, an URIError: URI malformed issue can have many origin, but a wrong ".npmrc" is the first place where you have to looking for !
Very useful. On my company PC I also had to add ´strict-ssl=false´ before the two lines ´proxy´ and ´https-proxy´
1

Might be one of following cases. Mine was second case. check your proxy : npm config get proxy

  1. If you have special characters in username or password , replace those characters with percent-encode [https://r12a.github.io/app-conversion/][1]

Say your password is password#123 - Get encoded version using above link which is password%23123 .

  1. If you have set proxy once without percent encoding, there is chance that this is saved in ".npmrc" in /Users/username and is not being updated when you run set config again with proper encoded password. You can directly edit ".npmrc" in that case.

Comments

0

Here is what worked for me. I was getting the same URI malformed exception.

My original URI format looked like this (I structured the URI this way based off of a popular answer in this question):

http://{domain}%5{username}:{password}/{baseURI}:{port}
i.e. http://COUNTRY%5bobjohnson:pass123/test.websitename.com:8080

What fixed it for me was removing the domain part of it and the %5 part.

Therefore the .npmrc file looked like this when it started working:

proxy=http://bobjohnson:pass123/test.websitename.com:8080
https-proxy=http://bobjohnson:pass123/test.websitename.com:8080

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.