Node.js
Source: [REF-1] Install Node.js Locally with Node Version Manager (nvm)
Install - FRESH nodejs using fnm, or nvm
fnm (Fast Node Manager) is the latest and recommended package manager now.
Updated: 2024 Jul
source: https://nodejs.org/en/download/package-manager/
# installs fnm (Fast Node Manager)
curl -fsSL https://fnm.vercel.app/install | bash
# download and install Node.js
fnm use --install-if-missing 20
# verifies the right Node.js version is in the environment
node -v # should print `v20.15.1`
# verifies the right NPM version is in the environment
npm -v # should print `10.7.0`
[Alternative] Install - nodejs using apt
Update nodejs version in WSL
Source: Install Node.js on Windows Subsystem for Linux (WSL2)
Tested (Jul 2024) on the following existing setup:
nvm
,nodejs
have been installed but older version then need to update; Current LTS version: v20.15.1;Inspect existing environments:
wsl:~$ node --version
v18.16.0
wsl:~$ npm --version
9.5.1
wsl:~$ nvm --version
0.39.3
wsl:~$ nvm ls
-> v18.16.0
default -> lts/* (-> v18.16.0)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.16.0) (default)
stable -> 18.16 (-> v18.16.0) (default)
lts/* -> lts/hydrogen (-> v18.16.0)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.0 (-> N/A)
lts/hydrogen -> v18.16.0
Update nodejs
# find the available versions
nvm ls-remote
nvm install 20.15.1
nvm install 20.15.1 --reinstall-packages-from=18.16.0
# upgrade npm if necessary
npm install -g npm@10.8.1
# uninstall old version
nvm uninstall 18.16.0
References
[REF-2] npm-doc Downloading and installing Node.js and npm
[REF3] Github Node Version Manager
[REF-4] DigitalOcean How To Install Node.js on Ubuntu 20.04
Last updated