How to upgrade node.js on Windows?

node.js

node.js Problem Overview


I already have Node.js v0.8.0 running on Windows. Can I just run the latest installer to upgrade it to v0.8.4? I am afraid it will break existing third party modules on my machine.

node.js Solutions


Solution 1 - node.js

Yes, you just install the latest version. Generally you shouldn't have any compatibility problems if you are already using the same major version (e.g. Version 0.8.x). If you are concerned about changes, you can always check the changelog for each version (link to changelog is on node.js download page at nodejs.org). That should tell you of any big changes (i.e API changes, etc).

Solution 2 - node.js

For the record, I have just gone through the process, and it is painless even if you upgrade to another major version.

I have moved from 0.8 to 0.10, using the .msi package, overwriting the one installed on my system. Package problems were all fixed with npm update -g. Worked like a charm.

In case it does not work like a charm:

npm cache clean usually fixes the problem. Once the cache is empty, just run npm update -g again.

In case you really run into trouble:

Delete the modules you have installed globally, then reinstall them. Here's how:

  • Take stock of what you have: npm list -g --depth=0 lists all top-level packages, with version numbers. npm list -g --parseable --depth=0 > npm-global-modules.txt writes them to a file in your cwd.

    Any strange stuff you didn't install yourself has probably been installed by another module (rare, but I have seen it happen). Remove those modules from the list. Also remove the module "npm".

  • In an editor, format the output for the command line by replacing \n?[^\n]+[\\/] (regex) with a single space.

    (I didn't get this to work with findstr in a pipe, hence the roundtrip to the editor. You can also do it manually, of course ;)

  • Delete all modules. On Windows, delete (or rename) the %appdata%\npm directory. For other OS, see https://stackoverflow.com/q/9283472/508355

  • Reinstall the modules with npm install -g [your module list here]. Don't forget to npm cache clean before you do it.

Solution 3 - node.js

I don't have experience with node on Windows, but I have just upgraded node & modules on my Mac, so this is just a general answer:

If you install v0.8, you might break your existing node modules, if they use deprecated functions, etc. The problem is that npm only checks your version of node while modules are being installed, not at run-time.

To be on the safe side, you need to find the global node_modules folder on your machine, back it up to somewhere, then delete and reinstall the modules. You will need to do the same thing for the node_modules folders in the apps you are using. (Assuming you have package.json files, reinstalling these should be easy.)

In practice, I don't think any of the modules I was using were actually incompatible. Good luck.

Solution 4 - node.js

Yes. You can upgrade your node.js version to the latest by running the installer for latest node.js version at https://nodejs.org/en/. I upgraded mine from 4.4.4 to 8.11.2 running the installer.

Solution 5 - node.js

Unless you're using a module that relies on an actual bug that was present in 0.8.0 and was fixed by 0.8.4, you're OK. There were no API changes in between those two versions (and the node team is too smart to introduce such changes in a minor release).

Solution 6 - node.js

Currently upgrading to 4.4.*. I just used to installer from the nodejs.org website and that upgraded everything works just fine.

Solution 7 - node.js

Just go to nodejs site & download it. You can install it directly without any hesitation. If you have any dependency on earlier version then check change logs.

Solution 8 - node.js

Best way to install node on windows is by using nvm-windows, so you can quickly switch between versions if you need to. This is analogous to the best way of installing node on linux and max, ie with nvm.

But Benjen is right (how could he not be with all his scouting experience) that you can just install a different version of node, and your version will update. Your npm dependencies may have to be reinstalled, and any extensions that aren't managed by npm may need to be recompiled, but this will be true no matter how you change your node version.

Solution 9 - node.js

JUST GO TO

nodejs.org

INSTALL THE LATEST STABLE VERSION (Recommended For Most Users)

and then run

npm install node

Now, you are good to go

You can even check the version of NodeJS using command

node --version

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpowerboyView Question on Stackoverflow
Solution 1 - node.jsBenjenView Answer on Stackoverflow
Solution 2 - node.jshashchangeView Answer on Stackoverflow
Solution 3 - node.jsrdreyView Answer on Stackoverflow
Solution 4 - node.jsIshara AmarasekeraView Answer on Stackoverflow
Solution 5 - node.jsebohlmanView Answer on Stackoverflow
Solution 6 - node.jsDaniel RodasView Answer on Stackoverflow
Solution 7 - node.jsJitendra PawarView Answer on Stackoverflow
Solution 8 - node.jsB TView Answer on Stackoverflow
Solution 9 - node.jssarthak bansalView Answer on Stackoverflow