LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux Deepin (https://www.linuxquestions.org/questions/linux-deepin-101/)
-   -   Help installing node.js (https://www.linuxquestions.org/questions/linux-deepin-101/help-installing-node-js-4175659280/)

RadioactiveButter 08-17-2019 12:46 AM

Help installing node.js
 
Hey there, I'm new to Linux and Deepin is my first distro. I'm trying to install Node.js to work through a beginner project but I'm not able to figure out what I'm doing wrong.

I've downloaded the files from here. Then I extracted them and followed the node website's instructions, typing this into the terminal:

curl -sL https://deb.nodesource.com/setup_10.x | bash - apt-get install -y nodejs

Output is:

bash: curl: command not found

Next I tried just

apt-get install -y nodejs

The output read E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?


I get that it doesn't recognize "curl" but I don't know what that is supposed to mean in the first place. In the second output I'm guessing it means that the location it needs to install to is locked and I need to have admin privileges which I do but I don't know how to put that in terminal.

I'm sure this is really basic stuff, but I'm pretty stuck. Thank you for any help.

teckk 08-17-2019 11:03 PM

Do you have curl installed? Doesn't look like it.
Code:

whereis curl
which curl

Admin means root.
You get root with su or use sudo if configured.
See: man su

Did you configure a root account when you installed? And a user?
https://wiki.deepin.org

ondoho 08-18-2019 02:55 AM

Quote:

Originally Posted by RadioactiveButter (Post 6026000)
curl -sL https://deb.nodesource.com/setup_10.x | bash - apt-get install -y nodejs

Ouch.
Bad command.
Let's go through this:
  • It downloads something (what? do you know what it does?) from the internet using curl.
  • then "pipes" it to bash (the pipe symbol: | ) which then executes it. Again, do you know what is being executed and why?
  • to make matters worse, it uses the apt-get install command with the '-y' switch, which means "just say yes to every question that requires user input". Seriously?
To make matters even worse, this won't work without elevated privileges, so I summarise:
A command to become root, download some random stuff from the internet and execute it, no questions asked.
Does that sound safe to you?

So how to do it properly?
  1. Make sure your system's up-to-date before you even start.
  2. Find the tutorial that tells you how to install nodejs
  3. erm, maybe nodejs is already in your distros repositories and you can install it from there instead? try 'apt search nodejs' and show us.

phil.d.g 08-18-2019 03:51 AM

RadioactiveButter,

You are just missing curl. Something that can download stuff using http(s). You can do this one of two ways. Do you know your root password? Did you provide it during install, or leave it blank?

If the former, then run the following command:

Code:

$ su -
And, enter that password.

Then install curl:

Code:

# apt install curl
Now you can follow those instructions again.

If you are using sudo (no root password), then do the following:

Code:

$ sudo apt install curl
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo bash - apt-get install -y nodejs



ondoho,

Quote:

Originally Posted by ondoho (Post 6026348)
So how to do it properly?
  1. Make sure your system's up-to-date before you even start.
  2. Find the tutorial that tells you how to install nodejs
  3. erm, maybe nodejs is already in your distros repositories and you can install it from there instead? try 'apt search nodejs' and show us.

Can I suggest that you perhaps read the documentation from nodejs's website on how to install on Debian. Specifically the part that talks about how NodeSource is the official source (as far as nodejs is concerned) of Debian nodejs packages, and that OP has pretty much copied their instructions verbatim. Also, note that the instructions has details on how to perform the installation manually should you (in their words) not be a fan of curl <url> | bash -. Also, note that these instructions reside in a git repo with the install script. Whilst your note may be good practice in the general sense, you've picked a really poor example to make your point.

ondoho 08-18-2019 04:15 AM

Quote:

Originally Posted by phil.d.g (Post 6026360)
Can I suggest that you perhaps read the documentation from nodejs's website on how to install on Debian.

Yes, I also suggested this to OP. Before executing random commands with superuser privileges. Good point.

Quote:

Originally Posted by phil.d.g (Post 6026360)
you've picked a really poor example to make your point.

Since OP is no doubt going to listen to you and not to me, let their success or failure, and their continued stability of their Mint installation, be the judge of that.


All times are GMT -5. The time now is 06:34 AM.