1
1

More than 1 year has passed since last update.

MacにNode.jsをインストール

Last updated at Posted at 2022-10-21

環境

% sw_vers
ProductName:	macOS
ProductVersion:	12.6
BuildVersion:	21G115
% 
% brew -v
Homebrew 3.6.6
Homebrew/homebrew-core (git revision c6c9e681ea6; last commit 2022-10-19)

インストール

1. nodebrew をインストール

% brew install nodebrew
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).

You have 1 outdated formula installed.
You can upgrade it with brew upgrade
or list it with brew outdated.

==> Downloading https://ghcr.io/v2/homebrew/core/nodebrew/manifests/1.2.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nodebrew/blobs/sha256:eed2aef
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/
######################################################################## 100.0%
==> Pouring nodebrew--1.2.0.all.bottle.tar.gz
==> Caveats
You need to manually run setup_dirs to create directories required by nodebrew:
  /opt/homebrew/opt/nodebrew/bin/nodebrew setup_dirs

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

To use Homebrew's directories rather than ~/.nodebrew add to your profile:
  export NODEBREW_ROOT=/opt/homebrew/var/nodebrew

zsh completions have been installed to:
  /opt/homebrew/share/zsh/site-functions
==> Summary
🍺  /opt/homebrew/Cellar/nodebrew/1.2.0: 8 files, 40.7KB
==> Running `brew cleanup nodebrew`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

% nodebrew
nodebrew 1.2.0

Usage:
...
(長いので省略)
...

2. nodebrew のセットアップ

インストールログに記載されている以下にしたがって、セットアップをする。

You need to manually run setup_dirs to create directories required by nodebrew:
  /opt/homebrew/opt/nodebrew/bin/nodebrew setup_dirs

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

3. node.js をインストール

% nodebrew install v16.18.0
Fetching: https://nodejs.org/dist/v16.18.0/node-v16.18.0-darwin-arm64.tar.gz
################################################################################################################### 100.0%
Installed successfully

% nodebrew list
v16.18.0

current: none

% nodebrew use v16.18.0
use v16.18.0

% nodebrew list        
v16.18.0

current: v16.18.0

% node -v
v16.18.0 

ex. その他のコマンド

  • インストール可能なバージョンを確認する。
    nodebrew ls-remote
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