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

More than 3 years have passed since last update.

【Mac】Nodeインストール手順の備忘録

Last updated at Posted at 2021-01-29

はじめに

  • Mac環境上で、Nodeの開発環境を構築する機会があったので、その備忘録です。
  • Nodeの管理ツールとして、nodebrewを使用しました。

Homebrewのインストール

zsh
# スクリプト実行
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# ログ
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
# ログイン時のPasswordを入力
Password:
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin
︙
Already up-to-date.
==> Installation successful!
# インストール確認
brew --version
# ログ
Homebrew 2.7.7

nodebrewのインストール

zsh
# インストール実行
brew install nodebrew
# Shellの確認
echo $SHELL
# → /bin/zsh
# .zshrcが無い場合、作成
touch .zshrc
# ~/.zshrcにnodebrewのPATHを追記
% echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.zshrc
# ファイル読み込み
source ~/.zshrc
# インストール確認
nodebrew
# → nodebrew 1.0.1 
# セットアップ実行
nodebrew setup

Node.jsのインストール

  • インストール可能なバージョンを確認します。
zsh
# インストール可能なバージョンを表示
nodebrew ls-remote
# → v0.0.1 v0.0.2 ~
# → v15.0.0 v15.1.0 ~
# → io@v1.0.0 io@v2.0.0 ~ 
  • バージョンを指定して、インストールします。
zsh
# v12.20.1をインストール
nodebrew install v12.20.1
  • インストール済みバージョンを確認します。
zsh
nodebrew list
# → v12.20.1
  • インストール済みバージョンを有効にします。
zsh
nodebrew use v12.20.1
node -v
# → v12.20.1
  • 別バージョンをインストールして、切り替えます。
zsh
# v14.15.3をインストール
nodebrew install v14.15.3
# インストール済みバージョンを表示
nodebrew list
# → v12.20.1
# → v14.15.3
# v14.15.3を有効化
nodebrew use v14.15.3
node -v
# → v14.15.3 
0
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
0
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?