LoginSignup
22
15

More than 5 years have passed since last update.

fishでnodeをインストール(Mac環境)

Last updated at Posted at 2018-10-08

nodebrewをインストール

$ brew install nodebrew

nodeの最新版をインストール

$ nodebrew install-binary latest

バージョンを指定したい場合は、

nodebrew ls-remote                                                                                                                                                                            (~) 14:15:44
v0.0.1    v0.0.2    v0.0.3    v0.0.4    v0.0.5    v0.0.6

〜〜〜〜〜〜〜〜〜〜

v0.9.0    v0.9.1    v0.9.2    v0.9.3    v0.9.4    v0.9.5    v0.9.6    v0.9.7
v0.9.8    v0.9.9    v0.9.10   v0.9.11   v0.9.12

v0.10.0   v0.10.1   v0.10.2   v0.10.3   v0.10.4   v0.10.5   v0.10.6   v0.10.7
v0.10.8   v0.10.9   v0.10.10  v0.10.11  v0.10.12  v0.10.13  v0.10.14  v0.10.15
v0.10.16  v0.10.17  v0.10.18  v0.10.19  v0.10.20  v0.10.21  v0.10.22  v0.10.23
v0.10.24  v0.10.25  v0.10.26  v0.10.27  v0.10.28  v0.10.29  v0.10.30  v0.10.31
v0.10.32  v0.10.33  v0.10.34  v0.10.35  v0.10.36  v0.10.37  v0.10.38  v0.10.39
v0.10.40  v0.10.41  v0.10.42  v0.10.43  v0.10.44  v0.10.45  v0.10.46  v0.10.47
v0.10.48

v0.11.0   v0.11.1   v0.11.2   v0.11.3   v0.11.4   v0.11.5   v0.11.6   v0.11.7
v0.11.8   v0.11.9   v0.11.10  v0.11.11  v0.11.12  v0.11.13  v0.11.14  v0.11.15
v0.11.16

〜〜〜〜〜〜〜〜〜〜

$ nodebrew install-binary v10.10.0

とする。

エラー対策

$ nodebrew install-binary latest
Fetching: https://nodejs.org/dist/v10.11.0/node-v10.11.0-darwin-x64.tar.gz
Warning: Failed to create the file
Warning: /Users/hondy12345/.nodebrew/src/v10.11.0/node-v10.11.0-darwin-x64.tar.
Warning: gz: No such file or directory
                                                                           0.0%
curl: (23) Failed writing body (0 != 1057)
download failed: https://nodejs.org/dist/v10.11.0/node-v10.11.0-darwin-x64.tar.gz

となってしまう場合があるが、この場合は ディレクトリを作ってあげるといい。

$ mkdir -p ~/.nodebrew/src/

バージョンの指定

# コンソールに出た以下の文言のvほにゃららを利用する
# Fetching: https://nodejs.org/dist/v10.11.0/node-v10.11.0-darwin-x64.tar.gz
$ nodebrew use v10.11.0
use v10.11.0

PATHを通す

fishの場合はexportではなくset -xを使う

$ set -x PATH $HOME/.nodebrew/current/bin $PATH

※永続化

~/.config/fish/config.fishは最初は存在しないが、新規作成すれば次回から読み込まれる

~/.config/fish/config.fish
set -x PATH $HOME/.nodebrew/current/bin $PATH

バージョン確認

$ node -v
v10.11.0
$ npm -v
6.4.1

こんな感じになればOK。

22
15
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
22
15