How to upgrade node.js on Windows?

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).


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 Command to remove all npm modules globally?

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


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.

Tags:

Node.Js