👻

Node Version Management "fnm" 【WSL2 ubuntu 20.04】

2022/04/08に公開

Library

https://github.com/Schniz/fnm

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>

Create .node_version file

$ 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