LoginSignup
0
1

More than 5 years have passed since last update.

ハイブリッドプロジェクト開発(二)Node.jsをインストールします

Last updated at Posted at 2019-03-27

本章では、JavaScriptプロジェクトを作成する前の準備の一つとして、Node.jsをインストルします。

npmインストル

npmとは、Node.jsに作られたライブラリやパッケージを管理する為のパッケージ管理ツールです。
npmをインストルする前に、Nodebrewをインストルすることが必要です。
Nodebrewは、Node.jsのバージョン管理ツールにあたります。

#nodebrewをインストル
brew install nodebrew
#Node.jsとnpmのインストール
nodebrew install-binary latest

もし、以下のエラーが出たら、下記のコマンドを実行して、ディレクトリを作成して、npmインストルを再度行います。
curl: (23) Failed writing body (0 != 941)
download failed: https://nodejs.org/dist/v7.10.0/node-v7.10.0-darwin-x64.tar.gz

mkdir -p ~/.nodebrew/src
nodebrew install-binary latest
#以下が表示
Fetching: https://nodejs.org/dist/v11.12.0/node-v11.12.0-darwin-x64.tar.gz
######################################################################## 100.0%
Installed successfully

上記のコマンドで最新版がインストールされます。
Node.jsを有効にします。

#バージョンの一覧を確認
nodebrew list
#バージョンの一覧が表示
v11.12.0
current: none
#current: noneとなっているため、必要なバージョンを有効化する。
nodebrew use v11.12.0
#バージョンの一覧を再確認
nodebrew list
#以下が表示
v11.12.0
current: v11.12.0

nodebrewが使いやすいように環境パスを通します。
インストルした結果を確認します。

echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
#node.jsがインストル済かどうかを確認
node -v
#以下が表示
v11.12.0
#npmがインストル済かどうかを確認
npm -v
#以下が表示
6.7.0

上記ような各バージョーンが表示されたらNode.jsのインストールが終わりします。


✨✨✨ 次の文章: ハイブリッドプロジェクト開発(三)Cordovaをインストールします

0
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
0
1