👻
Node Version Management "fnm" 【WSL2 ubuntu 20.04】
Library
Install
$ curl -fsSL https://fnm.vercel.app/install | bash
Setting
$ vim ~/.bashrc
↓
__fnm_use_if_file_found() {
if [[ -f .node-version || -f .nvmrc ]]; then
fnm use
fi
}
__fnmcd() {
\cd "$@" || return $?
__fnm_use_if_file_found
}
alias cd=__fnmcd
__fnm_use_if_file_found
↓
$ source ~/.bashrc
Usage
Change your directory
$ cd ~/<Your project folder>
.node_version
file
Create $ touch .node_version
<Your project folder>/.node_version
16.14.0
Node install
$ fnm install
=> Installing Node v16.14.0 (x64)
Use node this version
$ fnm use
=> Using Node v16.14.0
Check your node version
$ node -v
=> v16.14.0
Discussion