LoginSignup
1
0

More than 1 year has passed since last update.

【2022年版】MacにNodejsをインストールする方法

Posted at

はじめに

M1チップのMacbookでNodejsをインストールする方法をまとめた

Homebrewをインストール

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

※Homebrewをインストール済みの方は次の手順へ

インストール後は、次のコマンドでbrewコマンドが使えることを確認

brew -v

コマンドが使えない場合は下記参考

Nodebrewのインストール

brew install nodebrew

インストール後は下記のコマンドでバージョンを確認

nodebrew -v

続いて下記のコマンドを実行

nodebrew setup

下記のコマンドを実行し、Nodejsをインストール

nodebrew install-binary stable

インストール後に下記のコマンドを実行

nodebrew ls

実行例

v16.13.2

current: none

current :node となっているので、バージョンを指定する

Nodejsを有効化する

"nodebrew ls"のコマンドで出力されたバージョン番号で下記を実行

nodebrew use v16.13.2

環境パスを通す

Macデフォルトのzshをお使いの方

echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.zprofile

bashをお使いの方

echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile

ターミナルを再起動し、下記のコマンドでNodejsがインストールされていることを確認

node -v

終わりです

1
0
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
0