LoginSignup
15
8

nodebrewによるNode.jsのインストール手順まとめ

Posted at

はじめに

nodebrewによるNode.jsのインストール手順をまとめました。

実行環境

  • Apple M2 Max
  • macOS Ventura 13.2.1

インストール手順

準備:Homebrewをインストール

Homebrewがインストールされているかを確認。

brew -v

バージョンが表示されない場合はHomebrewをインストール。
(Homebrewのホームページにあるインストール用のスクリプトを実行)

nodebrewをインストール

以下のコマンドでnodebrewをインストール。

brew install nodebrew

インストールできたら以下のコマンドを実行しておく。

nodebrew setup

パスに関する記述を~/.zshrcに追加する。

export PATH=$HOME/.nodebrew/current/bin:$PATH

~/.zshrcを読み込む。

source ~/.zshrc

Node.jsをインストール

インストール可能なNode.jsバージョンを確認。

nodebrew ls-remote

バージョンを指定してNode.jsをインストール。

nodebrew install-binary v18.16.0

※安定版をインストールしたい場合は次のコマンドを実行

nodebrew install-binary stable

※最新版をインストールしたい場合は次のコマンドを実行

nodebrew install-binary latest

指定したバージョンがインストールされたかを確認。
(指定したバージョンが表示されたらOK)

nodebrew ls

使用するNode.jsバージョンを設定

使用するNode.jsのバージョンを指定する。

nodebrew use v18.16.0

使用されているNode.jsのバージョンを確認。
(指定したバージョンが表示されたらOK)

node -v
15
8
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
15
8