2

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.

David Foerster
  • 36,264
  • 56
  • 94
  • 147

2 Answers2

1

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.

abu_bua
  • 10,783
  • 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 ... ***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 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 ---

    – 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 00: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.........