Quantcast
Channel: Node.jsタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9013

Mac セットアップ(2)

$
0
0

コマンドラインインストール

brew

https://brew.sh/index_ja

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

途中でXCodeのインストール確認があるのでEnterを押す

Node

nodebrewでバージョンを管理したい

brew install nodebrew

途中経過

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).==> New Formulae
osm
==> Updated Formulae
Updated 10 formulae.

==> Downloading https://github.com/hokaccha/nodebrew/archive/v1.0.1.tar.gz
==> Downloading from https://codeload.github.com/hokaccha/nodebrew/tar.gz/v1.0.1
######################################################################## 100.0%==> Caveats
You need to manually run setup_dirs to create directories required by nodebrew:
  /usr/local/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=/usr/local/var/nodebrew

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions have been installed to:
  /usr/local/share/zsh/site-functions
==> Summary
🍺  /usr/local/Cellar/nodebrew/1.0.1: 8 files, 38.6KB, built in 2 seconds

インストールできたか確認

nodebrew -v

(成功した場合の)結果

nodebrew 1.0.1

Usage:
    nodebrew help                         Show this message
    nodebrew install<version>            Download and install<version> (from binary)
    nodebrew compile <version>            Download and install<version> (from source)
    nodebrew install-binary <version>     Alias of `install`(For backword compatibility)
    nodebrew uninstall <version>          Uninstall <version>
    nodebrew use <version>                Use <version>
    nodebrew list                         List installed versions
    nodebrew ls                           Alias for`list`
    nodebrew ls-remote                    List remote versions
    nodebrew ls-all                       List remote and installed versions
    nodebrew alias<key> <value>          Set alias
    nodebrew unalias<key>                Remove alias
    nodebrew clean <version> | all        Remove source file
    nodebrew selfupdate                   Update nodebrew
    nodebrew migrate-package <version>    Install global NPM packages contained in<version> to current version
    nodebrew exec<version> --<command>  Execute <command> using specified <version>

Example:
    # install
    nodebrew install v8.9.4

    # use a specific version number
    nodebrew use v8.9.4

zshにパスを追加

vi ~/.zsh_profile

以下を追加

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

セットアップをしてnodebrewのインストールを完了する

nodebrew setup

結果

Fetching nodebrew...
Installed nodebrew in$HOME/.nodebrew

========================================
Export a path to nodebrew:

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

Node v10.xをインストール

v10.22.0が最新なので以下のコマンドでインストールする

nodebrew install-binary v10.22.0

結果

Fetching: https://nodejs.org/dist/v10.22.0/node-v10.22.0-darwin-x64.tar.gz
############################################################################################################################################################################################### 100.0%
Installed successfully
rouc@roucnombp ~ %

インストールできたか確認

nodebrew ls

結果

v10.22.0

current: none

スイッチする

nodebrew use v10.22.0

スイッチされたか確認

nodebrew ls

結果

v10.22.0

current: v10.22.0 ## <<<--- 現在どのバージョンが使われているかが表示されている

Viewing all articles
Browse latest Browse all 9013

Trending Articles