1

This question already has an answer here:

trying to install Node js, but it seems like in the source files or package there in an extra space so error are there.

$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
W: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/trusty-­pgdg/main/binary-amd64/Packages  404  Not Found [IP: 204.145.124.244 80]
W: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/trusty-­pgdg/main/binary-i386/Packages  404  Not Found [IP: 204.145.124.244 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.

Error executing command, exiting

see, what seemed to me is, this links have extra space in the error urls

http://apt.postgresql.org/pub/repos/apt/dists/trusty- ­pgdg/main/binary-amd64/Packages

see trusty- ­pgdg the space before pgdg when I copy-pasted the url without the space, I was able to download the packages.

What should I do to solve this?

When I copy pasted it here, the space were gone, but I have attached the screen-shot.

marked as duplicate by David Foerster, karel, Fabby, guntbert, Kevin Bowen Jun 16 '18 at 17:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

If you want to install node.js you should install it via apt:

sudo apt-get install nodejs

You can list further node.js packages with following command:

apt search nodejs

Using the command

nodejs -v

you can check the installed verison.

  • root@mayank-Vostro-460:~# sudo apt-get install nodejs........... Reading package lists... Done......... Building dependency tree ........... Reading state information... Done......... nodejs is already the newest version..... 0 upgraded, 0 newly installed, 0 to remove and 377 not upgraded. .. root@mayank-Vostro-460:~# node -v ......... The program 'node' can be found in the following packages:....... * node..... * nodejs-legacy.... Try: apt-get install <selected package>... *****Does this means that NodeJS is installed? How do I check the installed version?**** – Mayank90 Jun 13 '18 at 13:26
  • root@mayank-Vostro-460:~# vi http_server.js ------------ root@mayank-Vostro-460:~# cat http_server.js ---------- var http = require('http'); -------------- http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(3000, "127.0.0.1"); console.log('Server running at 127.0.0.1:3000/'); ---------- root@mayank-Vostro-460:~# node http_server.js ----------------- The program 'node' can be found in the following packages: -------- * node---- * nodejs-legacy ----- Try: apt-get install <selected package>--- – Mayank90 Jun 13 '18 at 13:36
  • You can prove the current verison with: nodejs -v – abu_bua Jun 13 '18 at 14:04
  • @Mayank90: Could you please edit your post when you want to add information? Especially file or program output listings (with the help of the {} button in the editor toolbar) will be much more readable there; alternatively you can use a pastie service for longer listings and include the link of your pastie in your question. Overall it’s best to have everything relevant in one place. Additionally, comments may be deleted for various reasons. Thanks. – David Foerster Jun 16 '18 at 0:05
-2

https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/

//steps 0;;;;

//

sudo apt-get install curl python-software-properties

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

sudo apt-get install nodejs

//

//this will install things, even if some error are there, it may work fine.

//if this doesn't work.

//OR --- step 0;;;;;;;

Directly install nodejs from ubuntu software installer, binary file. **https://nodejs.org/en/download/

**Check version;;;;;;;;;;

node -v

v10.0.0

if above doesn't work,Try opening 2nd terminal & Check

node -v

if it's still not working, step2:::::::::

Having trouble to find the node in ubuntu 14.04 after installing

#which nodejs

**In my case it displayed /usr/bin/nodejs

**then Make a link, change environment variable or change node command path or something

#sudo ln -s /usr/bin/nodejs /usr/bin/node

------log----

root@mayank-Vostro-460:~# which node

root@mayank-Vostro-460:~# which nodejs

/usr/bin/nodejs

root@mayank-Vostro-460:~# sudo ln -s /usr/bin/nodejs /usr/bin/node

root@mayank-Vostro-460:~# node -v

v0.10.25

Check if node is working??

Step 4 – Create Demo Web Server (Optional) then check this from https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/

----------log----------

root@mayank-Vostro-460:~# vi http_server.js

root@mayank-Vostro-460:~# cat http_server.js

var http = require('http');

http.createServer(function (req, res) {

res.writeHead(200, {'Content-Type': 'text/plain'});

res.end('Hello World\n');

}).listen(3000, "127.0.0.1");

console.log('Server running at http://127.0.0.1:3000/');

root@mayank-Vostro-460:~# node http_server.js

The program 'node' can be found in the following packages:

  • node

  • nodejs-legacy

Try: apt-get install

root@mayank-Vostro-460:~# which node

root@mayank-Vostro-460:~# which nodejs

/usr/bin/nodejs

root@mayank-Vostro-460:~# sudo ln -s /usr/bin/nodejs /usr/bin/node

root@mayank-Vostro-460:~# node -v

v0.10.25

root@mayank-Vostro-460:~# node http_server.js

Server running at http://127.0.0.1:3000/


in Chrome or Firefox broweser open ;;;

127.0.0.1:3000/

output: Hello World...

So nodejs running.........

  • Please format your edit! – abu_bua Jun 15 '18 at 20:08
  • I have edited it. Its long, as I just wanted to shown the things, I did to solve this issue. – Mayank90 Jun 19 '18 at 6:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.