Nodejs install issue on ubuntu - node.js

I install nodejs using the following command on ubuntu
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Then it gives this message,
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 253 not upgraded.
W: Duplicate sources.list entry https://dl.bintray.com/sbt/debian/ Packages (/var/lib/apt/lists/dl.bintray.com_sbt_debian_Packages)
W: You may want to run apt-get update to correct these problems
When I do "sudo apt-get update", I get another error,
W: Failed to fetch http://ppa.launchpad.net/chris-lea/node.js/ubuntu/dists/wily/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/chris-lea/node.js/ubuntu/dists/wily/main/binary-i386/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/ole.wolf/rarcrack/ubuntu/dists/wily/main/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://ppa.launchpad.net/ole.wolf/rarcrack/ubuntu/dists/wily/main/binary-i386/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
Could you please let me know what how to correct that problem?

The errors occur because the four source links you (or some installer) added to your /etc/apt/sources.list are not found and return error 404.
If said entries are not in /etc/apt/sources.list, you can find them in some file /etc/apt/sources.list.d/*.list.
Delete the lines containing those urls in your /etc/apt/sources.list (or some file /etc/apt/sources.list.d/*.list) and install Node.js the official way:
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Or if you want version 6:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
Note
Maybe your running into that problem because your Ubuntu version is not supported.
I don't think they support 15.10, but only the LTS versions (14.04 & 16.04).
If you can, upgrade to 16.04 and try again.

Related

Error updating Node - ubuntu (WSL) - how to update node

I need at least any >14 version of node, but when i tried to update i had to uninstall. now i1m trying to install the 16 version but i keep gettimg this error:
Unpacking nodejs (16.19.0-deb-1nodesource1) ... dpkg: error processing
archive
/var/cache/apt/archives/nodejs_16.19.0-deb-1nodesource1_amd64.deb
(--unpack): trying to overwrite '/usr/include/node/common.gypi',
which is also in package libnode-dev 12.22.9~dfsg-1ubuntu3 dpkg-deb:
error: paste subprocess was killed by signal (Broken pipe) Errors were
encountered while processing:
/var/cache/apt/archives/nodejs_16.19.0-deb-1nodesource1_amd64.deb E:
Sub-process /usr/bin/dpkg returned an error code (1)
To install NodeJS Firstly make sure to update your packages
sudo apt update
sudo apt upgrade
Then make sure to have curl installed, sudo apt install curl -y
Then import NodeJS repo by curl -fsSL https://deb.nodesource.com/setup_NODEJS_VERSION | sudo -E bash -
Make sure to change NODEJS_VERSION to the version u wish to install, for example if u want to instal v16 change it to 16.x then simply run sudo apt install nodejs -y to install nodejs
Hope that helped!

I downloaded NodeJS from the official website but it doesn't work Ubuntu

On the official NodeJS website I downloaded the recommended windows installer. I tried on Ubuntu to see my version, node -v, and it doesn't work. When I type anything with node it says:
command 'node' not found, but can be installed with:
sudo apt install nodejs
I tried sudo apt install nodejs and I got another error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package nodejs
Trying npm is not any better
: not foundram Files/nodejs/npm: 3:
: not foundram Files/nodejs/npm: 5:
/mnt/c/Program Files/nodejs/npm: 6: Syntax error: word unexpected (expecting "in")
However, when I search node on the windows task bar, there is a node app that is listed and it opens a terminal. I'm new to Linux and it's my first time using Ubuntu, and I'm on windows 10, please advise me on what to do. Thanks.
Try, 'sudo apt update', then 'sudo apt install nodejs' -- no space between node and js
If that doesn't work:
Using Ubuntu
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Try this
sudo apt install curl
curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
then
nvm install stable

NodeJS is already installed but won't run

I'm running Ubuntu 18 on my VPS server, and I'm trying to run NodeJS, however, this happens:
seth#vps186104:~$ nodejs -v
Command 'nodejs' not found, but can be installed with:
sudo apt install nodejs
seth#vps186104:~$ sudo apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version (8.10.0~dfsg-2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
seth#vps186104:~$
It says to install the package to run nodejs, however, trying to install nodejs it says it's already installed
What is going on?
Try running:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Or if you want node 10.
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

Problems installing nodejs on Ubuntu 16.10

could someone help me to understand why it fails to find these packages?
sudo apt-get install -y nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libuv1
The following NEW packages will be installed:
libuv1 nodejs
0 upgraded, 2 newly installed, 0 to remove and 28 not upgraded.
Need to get 3.346 kB of archives.
After this operation, 14,1 MB of additional disk space will be used.
Err:1 http://it.archive.ubuntu.com/ubuntu yakkety/universe amd64 libuv1 amd64 1.9.1-1
404 Not Found
Err:2 http://it.archive.ubuntu.com/ubuntu yakkety/universe amd64 nodejs amd64 4.2.6~dfsg-1ubuntu5
404 Not Found
E: Failed to fetch http://it.archive.ubuntu.com/ubuntu/pool/universe/libu/libuv1/libuv1_1.9.1-1_amd64.deb 404 Not Found
E: Failed to fetch http://it.archive.ubuntu.com/ubuntu/pool/universe/n/nodejs/nodejs_4.2.6~dfsg-1ubuntu5_amd64.deb 404 Not Found
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
Try to install it like this
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Follow the Steps to install Nodejs using terminal.. Make sure your connected to internet
cd ~
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
nano nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs
After Installing Check the Version...
nodejs -v
Can also check the NPM version by
npm -v
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04
Or another way, you can use NVM to manage NodeJS version for your machine. NVM is stand for Node Version Manager.

Node not installed after installation

I installed nodejs using sudo apt-get, which appeared to continue perfectly.
If I now run sudo apt-get install nodejs it'll tell me:
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 113 not upgraded.
Yet, when I try to test node using node -v or node hello.js there is no reply. No error nothing.
How can I get it running?
Remove current nodejs package
sudo apt-get purge nodejs
and run the following command (node version 10)
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt update
sudo apt-get install -y nodejs
then check again
node -v

Resources