How to upgrade node.js on Windows?

后端 未结 9 863
悲哀的现实
悲哀的现实 2021-01-30 15:48

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 machi

相关标签:
9条回答
  • 2021-01-30 16:42

    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.

    0 讨论(0)
  • 2021-01-30 16:44

    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
    
    
    0 讨论(0)
  • 2021-01-30 16:46

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

    0 讨论(0)
提交回复
热议问题