LoginSignup
10
4

More than 1 year has passed since last update.

【Windows/Mac/Linux(Ubuntu)】Node.jsインストール方法

Posted at

Node.jsインストール方法【Windows】

  1. 以下のURLにアクセスする。
  2. 推奨版を押下する
    Node01.png
  3. フォルダを開く
    Node02.png
  4. node-v16.14.0-x64をダブルクリックする
    Node03.png
  5. Nextを押下する
    Node04.png
  6. チェックボックスにチェックをしてNextを押下する
    Node05.png
  7. Nextを押下する
    Node06.png
  8. Nextを押下する
    Node07.png
  9. Nextを押下する
    Node08.png
  10. Installを押下する
    Node09.png
  11. ダウンロード中
    Node10.png
  12. Finishを押下する
    Node11.png
  13. コマンドプロンプトを開き、 node --versionnpm --version コマンドを実行する
    Node12.png

Node.jsインストール方法【Mac】

Homebrewインストール

  • コマンド
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew -v
  • 実行例
% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
==> Checking for `sudo` access (which may request your password)...
Password:
==> You are using macOS 10.15.
==> We (and Apple) do not provide support for this old version.
This installation may not succeed.
After installation, you will encounter build failures with some formulae.
Please create pull requests instead of asking for help on Homebrew's GitHub,
Twitter or any other official channels. You are responsible for resolving any
issues you experience while you are running this old version.

==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew

Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /usr/sbin/chown -R 【ユーザ名】:admin /usr/local/Homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 12497, done.
remote: Counting objects: 100% (3870/3870), done.
remote: Compressing objects: 100% (31/31), done.
...省略
% brew -v
Homebrew 3.6.13
Homebrew/homebrew-core (git revision 22e4c30a566; last commit 2022-11-29)
Homebrew/homebrew-cask (git revision 62ecebffe4; last commit 2022-11-29)

Nodebrewインストールする

  • コマンド
brew install nodebrew
nodebrew -v
  • 実行例
% brew install nodebrew
==> Downloading https://ghcr.io/v2/homebrew/core/nodebrew/manifests/1.2.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/nodebrew/blobs/sha256:eed2aeff4fd05a4c2969d670ce9a38b
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:eed2aeff4fd05a4c2
######################################################################## 100.0%
==> Pouring nodebrew--1.2.0.all.bottle.tar.gz
==> Caveats
% nodebrew -v
nodebrew 1.2.0

Usage:
    nodebrew help                         Show this message
    nodebrew install <version>            Download and install <version> (from binary)
    nodebrew compile <version>            Download and install <version> (from source)
    nodebrew install-binary <version>     Alias of `install` (For backward compatibility)
    nodebrew uninstall <version>          Uninstall <version>
    nodebrew use <version>                Use <version>
    nodebrew list                         List installed versions
    nodebrew ls                           Alias for `list`
    nodebrew ls-remote                    List remote versions
    nodebrew ls-all                       List remote and installed versions
    nodebrew alias <key> <value>          Set alias
    nodebrew unalias <key>                Remove alias
    nodebrew clean <version> | all        Remove source file
    nodebrew selfupdate                   Update nodebrew
    nodebrew migrate-package <version>    Install global NPM packages contained in <version> to current version
    nodebrew exec <version> -- <command>  Execute <command> using specified <version>
    nodebrew prune [--dry-run]            Uninstall old versions, keeping the latest version for each major version

Example:
    # install
    nodebrew install v8.9.4

    # use a specific version number
    nodebrew use v8.9.4

Node.jsインストール

  • コマンド
nodebrew setup
nodebrew install-binary stable
nodebrew ls
nodebrew use 【バージョン】
nodebrew ls
  • 実行例
% nodebrew setup
Fetching nodebrew...
Installed nodebrew in $HOME/.nodebrew
...省略
% nodebrew install-binary stable
Fetching: https://nodejs.org/dist/v18.12.1/node-v18.12.1-darwin-x64.tar.gz
############################################################################################### 100.0%
Installed successfully
% nodebrew ls
v18.12.1

current: none
% nodebrew use v18.12.1
use v18.12.1
% nodebrew ls
v18.12.1

current: v18.12.1

環境パス設定

  • コマンド
echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
source ~/.bash_profile
  • 実行例
% echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
% source ~/.bash_profile

バージョン確認

  • コマンド
node -v
npm -v
  • 実行例
% node -v
v18.12.1
% npm -v
8.19.2

Node.jsインストール方法【Linux(Ubuntu)】

Node.jsインストール

  • コマンド
sudo apt update
sudo apt install nodejs
  • 実行例
$ sudo apt update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:2 https://download.docker.com/linux/ubuntu focal InRelease
Hit:3 https://deb.nodesource.com/node_12.x focal InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal InRelease  
...省略
$ sudo apt install nodejs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
...省略

npmパッケージインストール

  • コマンド
sudo apt install npm
  • 実行例
$ sudo apt install nodejs
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
...省略
この操作後に追加で 24.6 MB のディスク容量が消費されます。
続行しますか? [Y/n] y
...省略

バージョン確認

  • コマンド
node -v
npm -v
  • 実行例
$ node -v
v10.19.0
$ npm -v
6.14.4

参考文献

10
4
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
10
4