LoginSignup
23
24

More than 5 years have passed since last update.

nodebrewによるNode.jsのインストールからセットアップまで

Last updated at Posted at 2019-01-05

お疲れ様です。Node.js環境構築の項です。

ゴール

Node.jsを使えるようにする。

前提

やること

  1. nodebrewとは
  2. Node.jsとは
  3. nodebrewインストール
  4. nodebrewセットアップ
  5. Node.jsインストール
  6. Node.jsセットアップ
  7. npmを知る

1. nodebrewとは

  • Node.jsのバージョン管理ツール
  • 複数のバージョンを使い分けるために必要

2. Node.jsとは

Node.js.png

3. nodebrewインストール

terminal
$ brew install nodebrew

4. nodebrewセットアップ

$ nodebrew help に記載がないオプションコマンド。

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

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

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

PATHを通す。

terminal
$ echo '# nodebrew' >> ~/.bash_profile
$ echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
$ source .bash_profile

5. Node.jsインストール

  • stable:安定版
  • latest:最新版
terminal
$ nodebrew install stable

6. Node.jsセットアップ

  • Node.jsを有効にする。
  • インストールしたバージョンを確認する。
terminal
$ nodebrew use stable

$ nodebrew list
v10.15.0
current: v10.15.0

7. npmを知る

7-1. npmとは
7-2. npmセットアップ
7-3. npmパッケージ管理における今後の注意点

7-1. npmとは

  • Node Package Managerの略
  • パッケージ管理によってチーム内でJavaScript環境を共有する

7-2. npmセットアップ

Node.jsと共にインストールされている。
npmの存在を確認しておけば十分。

terminal
$ npm -v
6.4.1

$ which npm
/Users/ツーザ名/.nodebrew/current/bin/npm

7-3. npmパッケージ管理における今後の注意点

JavaScriptモジュール等は原則的にローカルインストール

お疲れ様でした。
この項・完

23
24
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
23
24