How do I update npm on Windows?

后端 未结 12 814
时光说笑
时光说笑 2020-12-04 09:37

When I install node 0.10.33 from the msi ( http://nodejs.org/download/ ), I get an old version of npm (1.4.28). How can I upgrade npm on Windows?

npm install

12条回答
  •  一整个雨季
    2020-12-04 10:07

    I did something similar to Sam Mikes. I'm only sharing this because I couldn't get either of his solutions to work on my rig. After a bit of playing around, this is what worked for me:

    1. Remove NPM/Node from your Environment Variables, both for user and system.
    2. Close your open console if you have one open, then open a console as administrator
    3. Change directories to %USERPROFILE% -- that's a window's environment variable that takes you to C:\Users\CurrentlyLoggedInUser
    4. Run from the console in %USERPROFILE%, "C:\Program Files\nodejs\npm" install npm -g (you might have yours in the x86 folder)
    5. If this solution would work for you, step 4 would have worked, and npm -v will show a an up-to-date version
    6. Re-add Node (in Program Files)/NPM (in App Data -- the one installed in Program Files should be the old one) to your user and system environment variables

    Note: I've used the Microsoft automated script in the past to fix this, but only because I didn't realize how easy it would be to do it myself.

提交回复
热议问题