LoginSignup
16
10

More than 1 year has passed since last update.

AWS EC2 AmazonLinux2 Node.jsをインストールしてnpmコマンドを使用できる様にする

Last updated at Posted at 2020-08-03

目的

  • AWS EC2のAmazonLinux2インスタンスにNode.jsを入れてnpmコマンドを使用できる様にする方法をまとめる

前提条件

  • 実施環境のリンク先の方法またはそれに準ずる方法で、AmazonLinux2インスタンスが作成され、ssh接続できること。

前提情報

  • 下記で実行するコマンドはAmazonLinux2インスタンスにsshでログインしてから実行する物とする。
  • 下記と同じ方法で構築したインスタンスでnpmコマンドを実行できる様にする。

読後感

  • インスタンス内でnpmコマンドを実行することができる。

概要

  1. リポジトリの追加
  2. インストール
  3. 確認

詳細

  1. リポジトリの追加

    1. 下記コマンドを実行してリポジトリを登録する。(ちなみに下記はNode.jsのバージョン12系のRed Hat系LinuxのNodeインストールコマンドである。その他のバージョンがほしければこちらに記載がある。→ https://github.com/nodesource/distributions#enterprise-linux-based-distributions

      $ curl -sL https://rpm.nodesource.com/setup_12.x | sudo bash -
      
  2. インストール

    1. 下記コマンドを実行してNode.jsをインストールする。

      $ sudo yum install --enablerepo=nodesource nodejs
      
    2. リポジトリが「nodesource」になっていることを確認してyを入力してEnterを押下する。

      web_php_—_test.png

  3. 確認

    1. 下記を実行してエラーメッセージが出ないことを確認する。

      $ npm
      
16
10
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
16
10