Go Back

Streamlining Node.js Projects on Windows: Using nvm-windows and npm-check-updates

11/05/20232 min read

Part 1: Node Version Management with nvm-windows

nvm-windows is a version manager for Node.js, allowing you to switch between Node versions without conflicts.

Installing nvm-windows

To install nvm-windows, follow these steps:

  1. Head over to the nvm-windows GitHub releases page.
  2. Download the latest nvm-setup.zip file.
  3. Unzip it and execute the nvm-setup.exe.
  4. Complete the setup wizard instructions.

Using nvm-windows

Open a new command prompt or PowerShell window to manage Node versions:

  • List installed Node versions: nvm list
  • Install a specific Node version: nvm install 14.17.0 (replace with your desired version)
  • Switch to use a specific Node version: nvm use 14.17.0
  • Set a default Node version: nvm alias default 14.17.0

Part 2: Keeping Dependencies Updated with npm-check-updates

npm-check-updates (ncu) updates your package.json with the latest versions of dependencies, ensuring you're using the most recent and secure packages.

Installing npm-check-updates

To install npm-check-updates, open your command prompt or PowerShell and enter:

npm install -g npm-check-updates

Using npm-check-updates

With ncu, you can easily check and update dependencies:

  • Check for outdated packages: ncu
  • Update package.json to the latest versions: ncu -u
  • Install updated packages: npm install

Best Practices for Using npm-check-updates

  • Check for updates regularly to keep dependencies fresh.
  • Review major version bumps for breaking changes before updating.
  • Run your test suite after updating to ensure compatibility.

Conclusion

For Windows-based Node.js developers, nvm-windows and npm-check-updates are essential tools for managing Node environments and dependencies. Incorporating these tools into your development process can significantly simplify version management and keep your projects up-to-date.