本来の目的:ローカル環境でES6を使用
node.jsのバージョン管理ツールnodebrewをインストール
※メリット:複数のnode.jsのバージョンを簡単に切り替えられる。
brewがインストールされているか確認
$brew-v
【実行結果】インストールされている
Homebrew2.2.6Homebrew/homebrew-core(gitrevisionba38;lastcommit2020-02-28)
nodebrewのインストール
$ brewinstallnodebrew
【実行結果】
UpdatingHomebrew...==>Auto-updatedHomebrew!Updated1tap(homebrew/core).==>NewFormulaeabseilhdf5@1.10publisharchiverhdtqpazcopyhsdsealbnfckillswitchswift-formatccheckmockoloswift-shcdk8smtoctlxcontainer-structure-testnefvpn-slicedhall-yamlnewrelic-clixclogparserforceclioilzimgit-trimopenlibm==>UpdatedFormulaenode✔less**(省略)**Removing:/Users/lancai/Library/Logs/Homebrew/yarn...(100B)Removing:/Users/lancai/Library/Logs/Homebrew/autoconf...(64B)Removing:/Users/lancai/Library/Logs/Homebrew/node...(64B)Removing:/Users/lancai/Library/Logs/Homebrew/rbenv...(64B)Pruned1symboliclinksand2directoriesfrom/usr/locallancai@ojaDesktop%
2分ほどでインストールが完了。
※10分以上かかる場合もあるとのこと
nodebrewのバージョン確認
$nodebrew
【実行結果】
nodebrew1.0.1Usage:nodebrewhelpShowthismessagenodebrewinstall<version>Downloadandinstall<version>(frombinary)nodebrewcompile<version>Downloadandinstall<version>(fromsource)nodebrewinstall-binary<version>Aliasof`install`(Forbackwordcompatibility)nodebrewuninstall<version>Uninstall<version>nodebrewuse<version>Use<version>nodebrewlistListinstalledversionsnodebrewlsAliasfor`list`nodebrewls-remoteListremoteversionsnodebrewls-allListremoteandinstalledversionsnodebrewalias<key><value>Setaliasnodebrewunalias<key>Removealiasnodebrewclean<version>|allRemovesourcefilenodebrewselfupdateUpdatenodebrewnodebrewmigrate-package<version>InstallglobalNPMpackagescontainedin<version>tocurrentversionnodebrewexec<version>--<command>Execute<command>usingspecified<version>Example:# installnodebrewinstallv8.9.4# use a specific version numbernodebrewusev8.9.4
私のバージョンは8.9.4
みたいです
Node.jsのインストール
実行環境の確認
$echo$SHELL
【実行結果】
/bin/zsh
/bin/zsh
の場合は以下を入力
$echo'export PATH=$HOME/.nodebrew/current/bin:$PATH'>>~/.zshrc
〜ここまでインストール準備完了〜
以下を一つずつ実行
$source~/.zshrc
$nodebrewsetup
実行結果
Fetchingnodebrew...Fetchingnodebrew...Installednodebrewin$HOME/.nodebrew========================================Exportapathtonodebrew:
exportPATH=$HOME/.nodebrew/current/bin:$PATH========================================
引き続き以下を実行
$ nodebrewusestable
実行結果
usev12.16.1
$node-v
実行結果
v12.16.0
Node.jsのバージョンが表示されたので無事にインストール出来たようです。