§2024-06-06
FNM(Fast Node Manager) - 另一個好用的 Node 版本管理工具 今天逛 Github 時突然發現 fnm 這個專案,它類似 nvm,是用來管理 node 版本的工具。
機器: n2Bookworm.yushei.com.tw
- Download Node.js, package manager
- using
fnm
stands for "Fast Node Manager". - Run JavaScript Everywhere
- Downloads Node.js v20.17.01 with long-term support.
# 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.14.0`
# verifies the right NPM version is in the environment
npm -v # should print `10.7.0`
@n2Bookworm.yushei.com.tw
alexlai@n2Bookworm:~/nodejs_project$ curl -fsSL https://fnm.vercel.app/install | bash
Checking dependencies for the installation script...
Checking availability of curl... OK!
Checking availability of unzip... OK!
Downloading https://github.com/Schniz/fnm/releases/latest/download/fnm-arm64.zip...
######################################################################## 100.0%
Installing for Bash. Appending the following to /home/alexlai/.bashrc:
# fnm
FNM_PATH="/home/alexlai/.local/share/fnm"
if [ -d "$FNM_PATH" ]; then
export PATH="$FNM_PATH:$PATH"
eval "`fnm env`"
fi
In order to apply the changes, open a new terminal or run the following command:
source /home/alexlai/.bashrc
alexlai@n2Bookworm:~/nodejs_project$ echo $PATH
/run/user/1026/fnm_multishells/12900_1717215462806/bin:/home/alexlai/.local/share/fnm:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
$ fnm install --lts
Installing Node v20.14.0 (arm64)
00:00:05 ███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ 23.62 MiB/23.62 MiB (4.05 MiB/s, 0s)
alexlai@hc4nas02:~$ fnm list
* v20.14.0 default, lts-latest
* system
alexlai@hc4nas02:~$ which node
/run/user/1026/fnm_multishells/865354_1717806322043/bin/node
alexlai@hc4nas02:~$ which npm
/run/user/1026/fnm_multishells/865354_1717806322043/bin/npm
alexlai@n2Bookworm:~$ node -v
v20.14.0
alexlai@n2Bookworm:~$ npm -v
10.7.0
alexlai@n2Bookworm:~$ fnm ls-remote
....
v20.9.0 (Iron)
v20.10.0 (Iron)
v20.11.0 (Iron)
v20.11.1 (Iron)
v20.12.0 (Iron)
v20.12.1 (Iron)
v20.12.2 (Iron)
v20.13.0 (Iron)
v20.13.1 (Iron)
v20.14.0 (Iron) <-- Iron is the code name
v21.0.0
v21.1.0
v21.2.0
v21.3.0
v21.4.0
v21.5.0
v21.6.0
v21.6.1
v21.6.2
v21.7.0
v21.7.1
v21.7.2
v21.7.3
v22.0.0
v22.1.0
v22.2.0
-
try the latest, 2024-05-15: node v22.2.0, npm: v10.7.0
alexlai@n2Bookworm:~$ fnm install 22.2.0
Installing Node v22.2.0 (arm64)
00:00:04 ███████████████████████████████████████████████████████████████████████████████████████████████████████████ 25.54 MiB/25.54 MiB (6.05 MiB/s, 0s)
alexlai@n2Bookworm:~$ node -v
v20.14.0
alexlai@n2Bookworm:~$ fnm use 22.2.0
Using Node v22.2.0
alexlai@n2Bookworm:~$ node -v
v22.2.0
alexlai@n2Bookworm:~$ npm -v
10.7.0