Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS EC2 : sudo: apt-get: command not found error

Tags:

amazon-ec2

I have installed Amazon Linux 2 AMI (HVM), SSD Volume Type second number of os in list (AWS console) in my instance.

It connect to putty successfully.

Now I want to install node in my server.

For that I go to /var folder. Then I run this command.

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -

And then I got error this.

## Populating apt-get cache...

+ apt-get update
bash: apt-get: command not found
Error executing command, exiting

To fixed this I have fire follow commands.

1) apt-get update
2) sudo apt-get update 
3) yum update 
4) sudo yum update

Still I have same issue. Anyone can help me.

like image 709
khushboo Avatar asked Feb 20 '26 15:02

khushboo


1 Answers

Install node version manager (nvm) by typing the following at the command line.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.0/install.sh | bash

Use nvm to install Node.js because nvm can install multiple versions of Node.js and allow you to switch between them.

Activate nvm by typing the following at the command line.

. ~/.nvm/nvm.sh

Use nvm to install the version of Node.js you intend to use by typing the following at the command line.

nvm install 4.4.5

Installing Node.js also installs the Node Package Manager (npm) so you can install additional modules as needed.

Test that Node.js is installed and running correctly by typing the following at the command line.

node -e "console.log('Running Node.js ' + process.version)"

This should display the following message that confirms the installed version of Node.js running.

Running Node.js v4.4.5

More Info : https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

like image 79
Valerian Pereira Avatar answered Feb 23 '26 09:02

Valerian Pereira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!