npxコマンドを使うためにNode.jsをインストールした話
はじめに
今回はNuxt.jsのプロジェクトを生成してくれるツールcreate-nuxt-app
を使うために用いるnpx
コマンドを実行できる環境を作ったのでまとめていこうと思う。
Homebrewでnodebrewをインストールした
私の場合、npxコマンドがなかったためnpxコマンドをHomebrewを用いて環境構築を行なった。
- nodebrewというversion管理パッケージをインストールした。(Rubyで言う所の
rbenv
)
$ brew install nodebrew
- 成功したら
~/.bash_profile
にてnodebrew内のパスを通す
$ echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile $ source ~/.bash_profile
- nodebrewの確認
$ nodebrew -v
- 最新版をインストール
$ nodebrew install-binary latest
以下のエラー文が出た場合はmkdir -p ~/.nodebrew/src
でダウンロード箇所を作ってあげましょう。
Fetching: https://nodejs.org/dist/v7.10.0/node-v7.10.0-darwin-x64.tar.gz Warning: Failed to create the file Warning: /Users/whoami/.nodebrew/src/v7.10.0/node-v7.10.0-darwin-x64.ta Warning: r.gz: No such file or directory curl: (23) Failed writing body (0 != 941) download failed: https://nodejs.org/dist/v7.10.0/node-v7.10.0-darwin-x64.tar.gz
- Node.jsの確認
$ node -v
- npmの確認
$ npm -v
- npxの確認
$ npx -v
参考にしたページ
終わりに
これで$ npx create-nuxt-app <projects>
を使える様になったので次回からNuxt.jsの基礎を勉強していこうと思う。