How to Install Node.js and npm on WSL2

Published Aug 19, 2021

We have a fresh installation of WSL2, and now we want to install node and npm.

Once we’ve opened up our Ubuntu terminal, we can run a few commands.

  1. Install cURL: sudo apt-get install curl
  2. Install nvm: curl -o- | bash

Be sure to change the v0.38.0 in the path to the most recent version available. If we install a newer version of nvm, it’ll replace the older one.

  1. Restart the terminal
  2. Verify installation: command -v nvm (it should return nvm)
  3. Install Node.js (two options)
    • Latest stable LTS release (recommended): nvm install --lts
    • Current release: nvm install node
  4. Verify installation:
    • Node.js: node --version
    • npm: npm --version

More CLI Articles