Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error Installing Nodejs, Ubuntu 18.04
#1
Exclamation 
Hey everyone, am new to Linux OS just switched from windows and i tried to install Nodejs on my system using the terminal but i keep  getting an error after running this code curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
i tried searching for answers but i couldn't find any related to my case, i use Ubuntu 18.04.2 LTS.

here is an attachment pic of my terminal


Attached Files
.png   Screenshot from 2019-06-02 09-47-26.png (Size: 130.73 KB / Downloads: 9)
Reply
#2
(06-02-2019, 09:05 AM)Norman Wrote: Hey everyone, am new to Linux OS just switched from windows and i tried to install Nodejs on my system using the terminal but i keep  getting an error after running this code curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
i tried searching for answers but i couldn't find any related to my case, i use Ubuntu 18.04.2 LTS.

here is an attachment pic of my terminal

Hi!
Thank you for including a screenshot, that makes troubleshooting
considerably easier, but...

Do not, ever, pipe the output of 'curl' into 'bash'.
This will get data from the internet and then bash tries to
interpret the data. Quite a severe security risk.

I assume you got the command from the official NodeJS GitHub page?
Well, it is still terrible advice and they should not recommend doing that.

Instead, install it manually following this guide. First, you will
add a PGP-key to your keyring, so the package can be verified. This
is motlikely the reason your previous attempt failed. Then You will
add a PPA to your repository list, which is basically a mini-repsoitory
for a single or small amount of packages. PPAs are also generally
not the best idea and can very easiely cause problems, but since
Ubuntu appearently does not package NodeJS itself, this is the
easiest option for installing it you have.
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply
#3
(06-02-2019, 02:38 PM)leon.p Wrote:
(06-02-2019, 09:05 AM)Norman Wrote: Hey everyone, am new to Linux OS just switched from windows and i tried to install Nodejs on my system using the terminal but i keep  getting an error after running this code curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
i tried searching for answers but i couldn't find any related to my case, i use Ubuntu 18.04.2 LTS.

here is an attachment pic of my terminal

Hi!
Thank you for including a screenshot, that makes troubleshooting
considerably easier, but...

Do not, ever, pipe the output of 'curl' into 'bash'.
This will get data from the internet and then bash tries to
interpret the data. Quite a severe security risk.

I assume you got the command from the official NodeJS GitHub page?
Well, it is still terrible advice and they should not recommend doing that.

Instead, install it manually following this guide. First, you will
add a PGP-key to your keyring, so the package can be verified. This
is motlikely the reason your previous attempt failed. Then You will
add a PPA to your repository list, which is basically a mini-repsoitory
for a single or small amount of packages. PPAs are also generally
not the best idea and can very easiely cause problems, but since
Ubuntu appearently does not package NodeJS itself, this is the
easiest option for installing it you have.

Thanks a lot leon.p i was able to get through the first step but the second is kinda confusing really need a master course on linux terminal basic Big Grin, need a little help braking down the second part the $VERSION and $DISTRO part am i supposed to substitute it for node version and linux distro? if i am, how am i supposed to type it? like for DISTRO should it be Ubuntu 18.04.2 LTS or something else?.
Reply
#4
For ubuntu 18.04 and node 12 it should be like this unless I'm reading it wrong:

# Replace with the branch of Node.js or io.js you want to install: node_6.x, node_8.x, etc...
VERSION=node_12.x
# The below command will set this correctly, but if lsb_release isn't available, you can set it manually:
# - For Debian distributions: jessie, sid, etc...
# - For Ubuntu distributions: xenial, bionic, etc...
# - For Debian or Ubuntu derived distributions your best option is to use the codename corresponding to the upstream release your distribution is based off. This is an advanced scenario and unsupported if your distribution is not listed as supported per earlier in this README.
DISTRO="bionic"
echo "deb https://deb.nodesource.com/node_12.x bionic main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/node_12.x bionic main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list
Reply
#5
(06-02-2019, 06:14 PM)Norman Wrote: Thanks a lot leon.p i was able to get through the first step but the second is kinda confusing really need a master course on linux terminal basic Big Grin, need a little help braking down the second part the $VERSION and $DISTRO part am i supposed to substitute it for node version and linux distro? if i am, how am i supposed to type it? like for DISTRO should it be Ubuntu 18.04.2 LTS or something else?.

There are code sections in the explanation I linked to.

Code:
Kinda similar to this one :)

Every line that starts with '#' is a comment, bash will ignore it.
You, however, should not ignore them, as they usually explain what
the code around them does.

Every line not starting with '#' is supposed to be typed into the
terminal and executed.



Here are all the commands shown on the page:

Code:
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -

'curl' will fetch the PGP key found behind the URL. It is then
piped into 'apt-key', which will add the key to its keyring.
Apt is responsible for downloading packaged programs and their
dependencies from the repositories and using 'dpkg' to install
them. The keys in the key-ring are used to validate the packages,
making sure they are valid so that an evil-doer can not easiely
inject malicious packages onto your computer.

Code:
VERSION=node_8.x

Bash, as most computer languages, has variables. Just because
you are using bash in interactive mode (as the shell in your
terminal, the program that interprets commands you execute)
does not mean you can not use them. This line will simple set
the variable called 'VERSION' to the string "node_8.x".

Code:
DISTRO="$(lsb_release -s -c)"

This is also a variable. What this line will do is execute
the command 'lsb_release -s -c' and storing its output in the
variable called 'DISTRO'.

Code:
echo "deb https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list

These two commands will simply add a PPA (a mini-repository,
as I eplained in my other post) to the list of repositories
apt uses. '$VERSION' and '$DISTRO' will automatically be
substituted to the contents of the variables by bash.

Code:
sudo apt-get update
sudo apt-get install nodejs

These two commands will update apts repository cache and then
install NodeJS.




In other words, there is nothing for your to manually do
and also nothing to understand: Just execute the commands
as they are shown in the explanation.
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply
#6
(06-02-2019, 08:55 PM)leon.p Wrote:
(06-02-2019, 06:14 PM)Norman Wrote: Thanks a lot leon.p i was able to get through the first step but the second is kinda confusing really need a master course on linux terminal basic Big Grin, need a little help braking down the second part the $VERSION and $DISTRO part am i supposed to substitute it for node version and linux distro? if i am, how am i supposed to type it? like for DISTRO should it be Ubuntu 18.04.2 LTS or something else?.

There are code sections in the explanation I linked to.

Code:
Kinda similar to this one :)

Every line that starts with '#' is a comment, bash will ignore it.
You, however, should not ignore them, as they usually explain what
the code around them does.

Every line not starting with '#' is supposed to be typed into the
terminal and executed.



Here are all the commands shown on the page:

Code:
curl -sSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -

'curl' will fetch the PGP key found behind the URL. It is then
piped into 'apt-key', which will add the key to its keyring.
Apt is responsible for downloading packaged programs and their
dependencies from the repositories and using 'dpkg' to install
them. The keys in the key-ring are used to validate the packages,
making sure they are valid so that an evil-doer can not easiely
inject malicious packages onto your computer.

Code:
VERSION=node_8.x

Bash, as most computer languages, has variables. Just because
you are using bash in interactive mode (as the shell in your
terminal, the program that interprets commands you execute)
does not mean you can not use them. This line will simple set
the variable called 'VERSION' to the string "node_8.x".

Code:
DISTRO="$(lsb_release -s -c)"

This is also a variable. What this line will do is execute
the command 'lsb_release -s -c' and storing its output in the
variable called 'DISTRO'.

Code:
echo "deb https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list

These two commands will simply add a PPA (a mini-repository,
as I eplained in my other post) to the list of repositories
apt uses. '$VERSION' and '$DISTRO' will automatically be
substituted to the contents of the variables by bash.

Code:
sudo apt-get update
sudo apt-get install nodejs

These two commands will update apts repository cache and then
install NodeJS.




In other words, there is nothing for your to manually do
and also nothing to understand: Just execute the commands
as they are shown in the explanation.

wow thanks a lot for everything i have installed node successfully, you explained everything so clearly i've
 got nothing to be afraid of with someone like you around Thanks for the support  Big Grin

(06-02-2019, 08:06 PM)spudnuts Wrote: For ubuntu 18.04 and node 12 it should be like this unless I'm reading it wrong:

# Replace with the branch of Node.js or io.js you want to install: node_6.x, node_8.x, etc...
VERSION=node_12.x
# The below command will set this correctly, but if lsb_release isn't available, you can set it manually:
# - For Debian distributions: jessie, sid, etc...
# - For Ubuntu distributions: xenial, bionic, etc...
# - For Debian or Ubuntu derived distributions your best option is to use the codename corresponding to the upstream release your distribution is based off. This is an advanced scenario and unsupported if your distribution is not listed as supported per earlier in this README.
DISTRO="bionic"
echo "deb https://deb.nodesource.com/node_12.x bionic main" | sudo tee /etc/apt/sources.list.d/nodesource.list
echo "deb-src https://deb.nodesource.com/node_12.x bionic main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list

thanks a lot that cleared my confusion, you guys are awesome  Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)