How to upgrade node.js on Windows?
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.
Solution 1:
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:
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 tonpm cache clean
before you do it.
Solution 3:
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:
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:
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).