Nodejs on WSL2

1. Node Version Manager(nvm)

1.1 change the source of node install

for Chinese user, change it to the Taobao mirror
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node

1.2 Common commands

  • list all installed node
    nvm ls
  • install the latest version
    nvm install node
  • install the long term supported version
    nvm install --lts
  • check node/npm version
    node --version
    npm --version
  • change the version of Node in used
    nvm use node
    nvm use --lts