Are you first timer at lazacode.org? Why not join us and start exchange your programming knowledge with everyone. Register today!

Node JS - Switch Node version in windows with nvm-windows switcher

0 votes
550 views
added Dec 9, 2020 in Node JS by lcjr Second Warrant Officer (3,820 points)
edited Dec 9, 2020 by lcjr

Reason to use; nvm mainly used in Mac/linux environment, but not in windows, and nvm-windows just do exactly this (for windows)

Some of the project requires later Node version, while some only worked with older version. That's why we need a node version switcher to toggle between the 2. Here's how to configure it. 

  1. Uninstall existing Node.js from windows
  2. Delete any existing Node.js directories (e.g., "C:\Program Files\nodejs)
  3. Delete the existing npm install location (e.g. "C:\Users\<user>\AppData\Roaming\npm") to avoid global module conflicts. 
  4. Backup any global npmrc config (e.g. C:\Users\<user>\AppData\Roaming\npm\etc\npmrc), or copy the settings to the user config C:\Users\<user>\.npmrc.
  5. Download latest nvm-windows installer here https://github.com/coreybutler/nvm-windows/releases
  6. install the nvm-windows installer
  7. Open shell and run 'nvm install 12' to install Node 12.0 
  8. And runs 'nvm install 8.15' to install Node 8.15 
  9. check npm command whether its works, else need to uninstall and reinstall node version for compatible environment.
  10. Run nvm use 12 or nvm use 8.15 to switch between the project. 
  11. Run npm i or npm install to ensure dependencies of each Node v is correct
  12. If you plan to use yarn, run npm i -g yarn for a start.
  13. Follow by npm or yarn command for development commands.
  14. To update project; repeat step 10. 

Head on here to for nvm-windows README.md here https://github.com/coreybutler/nvm-windows/blob/master/README.md

Please log in or register to response this reference.

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...