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

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!

Related

Cannot install nodejs on ubuntu 22.04

im trying to install NodeJS LTS on my vm. But ubuntu (22.04) throws an error
Error:
root#web-server ~/server# sudo apt list nodejs
Listing... Done
nodejs/unknown 18.12.0-deb-1nodesource1 arm64
N: There is 1 additional version. Please use the '-a' switch to see it
root#web-server ~/server# sudo apt install nodejs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
javascript-common libc-ares2 libjs-highlight.js libnode72
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
nodejs
0 upgraded, 1 newly installed, 0 to remove and 93 not upgraded.
Need to get 0 B/27.8 MB of archives.
After this operation, 180 MB of additional disk space will be used.
(Reading database ... 83553 files and directories currently installed.)
Preparing to unpack .../nodejs_18.12.0-deb-1nodesource1_arm64.deb ...
Unpacking nodejs (18.12.0-deb-1nodesource1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_18.12.0-deb-1nodesource1_arm64.deb (--unpack):
trying to overwrite '/usr/share/systemtap/tapset/node.stp', which is also in package libnode72:arm64 12.22.9~dfsg-1ubuntu3
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_18.12.0-deb-1nodesource1_arm64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root#web-server ~/server [100]#
I tried to delete and install it again multiple times bu nothing happens
Follow this link: Github Error solved link
and reinstall nodejs with the following command as given below
Installed Nodejs version-12.22.9 Successfully on my Ubuntu 22.04
sudo apt update
sudo apt install nodejs
Press Y when prompted to confirm installation. If you are prompted to restart any services, press ENTER to accept the defaults and continue. Check that the install was successful by querying node for its version number:
node -v
Output
v 12.22.9
Try this:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
$ source ~/.bashrc
$ nvm list-remote
$ nvm install v16.14.0
$ nvm install lts/fermium
$ node -v
These steps will install nodejs v14.19.0.
There is a very helpful link to setup or update nodejs on Ubuntu 22.4
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-22-04
you can visit it for more details.

Nodejs install issue on ubuntu

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.

Installing sublime text 3 on AWS Ubuntu 14.04.1 LTS

Sublime-text is a fast editor for Windows and Linux. I failed to install sublime text 3 on AWS Ubuntu 14.04.1 LTS using the following commands:
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer
Results in following error message:
p: cannot create regular file "/usr/share/icons/hicolor/16x16/apps/":
No such file or directory dpkg: error processing package sublime-text-installer (--configure):
subprocess installed post-installation script returned error exit status 1
I see following directories under /usr/share/icons/hicolor/
32
48
64
So, I created 16x16 subdirectory, but then it gives an error for 32x32 directory doesnot exist. Did anyone experience this problem before? I will appreciate any help.
sublime-text is a GUI application that needs a GTK installation. Your server is missing that dependency. (In a perfect world, it should be a dependency of the package of course.)
Install libgtk2 (as root):
apt-get install libgtk2.0-common
and then reinstall sublime-text, probably using:
apt-get purge sublime-text-installer ; apt-get install sublime-text-installer

Error on "update-alternatives" when installing/upgrading nodejs v0.10.30

So I get this error when doing apt-get upgrade
Setting up nodejs (0.10.30-1chl1~trusty1) ...
update-alternatives: error: alternative link /usr/bin/node is already managed by nodejs
dpkg: error processing package nodejs (--configure): subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing: nodejs
E: Sub-process /usr/bin/dpkg returned an error code (1)
NB: "nodejs --version" works, I get a clean "v0.10.30" but "node --version" doesn't since there is no link.
So far, I have tried:
complete removal of nodejs & new install
I manually removed the link /usr/bin/node to nodejs after removing nodejs, since it was still there and the issue is related to update-alternatives
using "update-alternatives --config nodesjs" (something was broken and repaired the first time I used it, but it didn't solve the issue. That error has not reappeared since).
Other answers didn't resolved the problem on my setup, maybe because I was using the NodeSource repository instead of the official ones.
But I've simply removed all "alternatives" for the nodejs group first:
sudo update-alternatives --remove-all nodejs
And after that, a sudo apt-get install nodejs just worked.
I really encourage you to use nvm to install Node.js on your ubuntu machine (https://github.com/creationix/nvm). With that, the installation of any Node.js version becomes very easy.
Probably you have an older version of NodeJS installed and you get a conflict while upgrading.
The only package that uses /usr/bin/node is nodejs-legacy, so unless you have created that link by yourself or installed NodeJS from sources that's the package you need to remove:
$ sudo apt-get purge nodejs-legacy nodejs
After that just reinstall NodeJS, update and upgrade your software:
$ sudo apt-get install nodejs
$ sudo apt-get update && sudo apt-get upgrade
From the output you gave the NodeJS version from the PPA has priority over the other, so you should not have any problem installing it.

how to tell "dpkg" to NOT to download / install a broken source?

Whenever I try to use apt-get/dpkg, it tries a to install a broken source.
How can I tell it to NOT do so ?
here is its error:
dpkg: error processing oracle-java7-installer (--configure):
subprocess installed post-installation script returned error exit status 1
E: Sub-process /usr/bin/dpkg returned an error code (1)
UPDATE :
I found the perfect solution here:
https://askubuntu.com/questions/121226/how-to-completely-remove-a-oracle-jdk-that-didnt-install-properly
You need to define does this package depends on something and do you need it. If not just force to purge it with
aptitude purge oracle-java7-installer
or even
dpkg --force-all --purge oracle-java7-installer
If you need it try to determine why it is broken. Due to your posted error there is broken script in installer. So you'll need to fix it. The simplest way is to unpack it, fix script and repack. After that install should success.
you also need to install aptitude first as it is no longer default installed.
and use sudo privileges.
sudo apt-get install aptitude
and
sudo aptitude purge oracle-java7-installer
or
sudo dpkg --force-all --purge oracle-java7-installer

Resources