0
Help us understand the problem. What are the problem?

posted at

updated at

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>

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

Register as a new user and use Qiita more conveniently

  1. You can follow users and tags
  2. you can stock useful information
  3. You can make editorial suggestions for articles
What you can do with signing up
0
Help us understand the problem. What are the problem?