0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

EC2 Amazon LinuxへNode.jsを導入する

Posted at

以下のコマンドを実行するだけで簡単にインストール出来ました。

sudo yum update -y
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
. ~/.nvm/nvm.sh
nvm install --lts
node --version
npm --version
,     #_
   ~\_  ####_        Amazon Linux 2023
  ~~  \_#####\
  ~~     \###|
  ~~       \#/ ___   https://aws.amazon.com/linux/amazon-linux-2023
   ~~       V~' '->
    ~~~         /
      ~~._.   _/
         _/ _/
       _/m/'
[ec2-user@ip-***-***-***-*** ~]$ 
[ec2-user@ip-***-***-***-*** ~]$ ls
[ec2-user@ip-***-***-***-*** ~]$ pwd
/home/ec2-user
[ec2-user@ip-***-***-***-*** ~]$ node
-bash: node: command not found
[ec2-user@ip-***-***-***-*** ~]$ node --version
-bash: node: command not found
[ec2-user@ip-***-***-***-*** ~]$ npm --version
-bash: npm: command not found
[ec2-user@ip-***-***-***-*** ~]$ sudo yum update -y
Amazon Linux 2023 Kernel Livep 138 kB/s |  19 kB     00:00    
Dependencies resolved.
Nothing to do.
Complete!
[ec2-user@ip-***-***-***-*** ~]$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:--100 15916  100 15916    0     0   917k      0 --:--:-- --:--:-- --:--:--  971k
=> Downloading nvm as script to '/home/ec2-user/.nvm'

=> Appending nvm source string to /home/ec2-user/.bashrc
=> Appending bash_completion source string to /home/ec2-user/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
[ec2-user@ip-***-***-***-*** ~]$ . ~/.nvm/nvm.sh
[ec2-user@ip-***-***-***-*** ~]$ nvm install --lts
Installing latest LTS version.
Downloading and installing node v22.18.0...
Downloading https://nodejs.org/dist/v22.18.0/node-v22.18.0-linux-x64.tar.xz...
######################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v22.18.0 (npm v10.9.3)
Creating default alias: default -> lts/* (-> v22.18.0)
[ec2-user@ip-***-***-***-*** ~]$ nvm use --lts
Now using node v22.18.0 (npm v10.9.3)
[ec2-user@ip-***-***-***-*** ~]$ node --version
v22.18.0
[ec2-user@ip-***-***-***-*** ~]$ npm --version
10.9.3
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?