LoginSignup
0
1

More than 1 year has passed since last update.

Node.jsをインストールする

Last updated at Posted at 2021-01-12

何?Node.jsって?

Node.js はスケーラブルなネットワークアプリケーションを構築するために設計された非同期型のイベント駆動の JavaScript 環境です。
Node.js とは | Node.js

Windowsにインストーラでインストールする

  • 環境 : Windows10 Pro バージョン1909
  1. Node.jsのダウンロードページを表示してインストーラをダウンロードする
    • 古めのバージョンは、リリース一覧 | Node.jsから探してダウンロード
    • 今回は古めのnode-v10.23.1-x64.msiをダウンロード
  2. インストーラを起動して[Next]ボタンでどんどん進んで[Install]ボタンでインストールするimage.pngimage.pngimage.pngimage.pngimage.pngimage.pngimage.png
  3. バージョンを確認する
バージョンを確認する
# インストーラが自動でパスを通してくれているのでnodeやnpmコマンドが使えるようになっている
$ printenv PATH | sed -e 's/:/:\n/g' | grep -i node
/c/apps/nodejs:

$ node -v
v10.23.1

$ npm -v
6.14.10

$ npm bin -g
C:\Users\ponsuke\AppData\Roaming\npm

MacにHomebrewでインストールする

  • 環境 : macOS BigSur バージョン11.3.1

事前準備

久しぶりにHomebrewを使う場合は、インストールする前にHomebrewを更新したり、健康状態を確認したりする。

# 1.アップデートしておく
$ brew update
#...省略...
You have 7 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

# 2.ちょっと古くなってそうなのでアップグレードもしておく
$ brew upgrade
Updating Homebrew...
#...省略...

# 3.バージョンを見ておく
$ brew -v
Homebrew 3.2.6
Homebrew/homebrew-core (git revision 5504bf6c84; last commit 2021-08-09)
Homebrew/homebrew-cask (git revision 18b2943ede; last commit 2021-08-09)

# 4.Homebrewが元気かお医者さんに聞いておく
$ brew doctor
Your system is ready to brew.

# 5.インストールしちゃってないか確認する
$ brew list | grep node

# 6.Node.jsを検索するとバージョン違いがいくつかあるのでインストールするものを決める
$ brew search node
==> Formulae
libbitcoin-node          node                     node-sass                node@12                  node_exporter            nodeenv                  ode
llnode                   node-build               node@10                  node@14                  nodebrew                 nodenv
#...省略...

# 7.今回は「node」をインストールする
$ brew info node
node: stable 16.6.1 (bottled), HEAD
Platform built on V8 to build network applications
#...省略...

インストールする

$ brew install node
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 2 formulae.

==> Downloading https://ghcr.io/v2/homebrew/core/brotli/manifests/1.0.9
#...省略...
==> Installing dependencies for node: brotli, c-ares, icu4c, libuv, jemalloc, libev, openssl@1.1 and nghttp2
==> Installing node dependency: brotli
==> Pouring brotli--1.0.9.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/brotli/1.0.9: 25 files, 2.4MB
==> Installing node dependency: c-ares
==> Pouring c-ares--1.17.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/c-ares/1.17.1: 85 files, 672.5KB
==> Installing node dependency: icu4c
==> Pouring icu4c--69.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/icu4c/69.1: 259 files, 72.8MB
==> Installing node dependency: libuv
==> Pouring libuv--1.42.0.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libuv/1.42.0: 49 files, 3.4MB
==> Installing node dependency: jemalloc
==> Pouring jemalloc--5.2.1_1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/jemalloc/5.2.1_1: 16 files, 2MB
==> Installing node dependency: libev
==> Pouring libev--4.33.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/libev/4.33: 12 files, 484.0KB
==> Installing node dependency: openssl@1.1
==> Pouring openssl@1.1--1.1.1k.big_sur.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /usr/local/Cellar/openssl@1.1/1.1.1k: 8,071 files, 18.5MB
==> Installing node dependency: nghttp2
==> Pouring nghttp2--1.44.0.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/nghttp2/1.44.0: 23 files, 2.8MB
==> Installing node
==> Pouring node--16.6.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/node/16.6.1: 2,504 files, 48.3MB

# zshのcorrect機能が有効な場合は、はじめて「node」って打つと誤記っているのかと勘違いされますが、「n(誤記じゃないよ)」ってしておけばOK!
$ node -v
zsh: correct 'node' to 'od' [nyae]?n
v16.6.1

# 次からは誤記扱いされません
$ node -v
v16.6.1

# npm(Node Package Manager)は、パッケージ管理ツールです。
$ npm -v
7.20.3

Yarnもインストールする

npmがインストールされているのでnpmを使ってインストールします。

# npmでyarnをインストール(ついでにnpmのアップデートもしてくれた)
$ npm install --global yarn

added 1 package, and audited 2 packages in 877ms

found 0 vulnerabilities
npm notice 
npm notice New minor version of npm available! 8.18.0 -> 8.19.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.19.1
npm notice Run npm install -g npm@8.19.1 to update!
npm notice 

# zshのcorrect機能が有効な場合は、はじめて「yarn」って打つと誤記っているのかと勘違いされますが、「n(誤記じゃないよ)」ってしておけばOK!
$ yarn -v
zsh: correct 'yarn' to 'tar' [nyae]? n
1.22.19
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