1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Windows】fnmを使って指定したバージョンのNodeを特定のフォルダ配下に適用する

Posted at

はじめに

fnmを使って、WSL2環境で指定したバージョンのNodeを特定のフォルダ配下に適用する手順をまとめます。
例えばですが、project/aws配下に下記を適用していくとします。

Node.js yarn
14.21.3 1.22.22

fnmとは
Node.jsのバージョンを管理するものです。
スピード性を重視しており、Nodeインストール時にはこちらを使うことが推奨されています。
fnmのインストール方法は下記のサイトに記載されています。

手順

project/aws配下(Nodeを使用したい場所)で希望するNodeのバージョンを指定してインストールします。

fnm install 14.21.3

Windowsの場合、環境変数の設定をPowerShellに適用してfnm useを有効にします。
PowerShell配下で下記を実行しておかないとfnm useを使用できません。

fnm env --use-on-cd | Out-String | Invoke-Expression

Nodeを使用したいフォルダ配下に移動してfnm use [node version]を行うと、その通りに適用されます。

fnm use 14.21.3

node-v14.21.3(指定したNodeのバージョン)が出ていれば成功です。


希望のバージョンのyarnをグローバルにインストールする方法も追記します。
これでfnmによって切り替えたNodeバージョン(今回はv14.21.3)に紐づくnpmのglobal領域にインストールされるため、このバージョンのNodeを使っているときにだけ、指定したバージョンのYarnが使えます

npm install -g yarn@1.22.22

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?