Nodejs package cannot be installed in ubuntu - node.js

i am on Ubuntu 22.04
i cannot install nodejs after uninstalling previous node version and i do not know if the source or repo is conflicting.
i got node version 12 installed when i first run this command
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
later, i wanted version node 18 so i apt-get remove node and i run this command
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
after, i run
sudo apt-get install -y nodejs
and now i am getting dpkg-deb errors
After this operation, 184 MB of additional disk space will be used. Get:1 https://deb.nodesource.com/node_18.x jammy/main amd64 nodejs amd64 18.13.0-deb-1nodesource1 [28.4 MB] Fetched 28.4 MB in 44s (641 kB/s) (Reading database ... 213677 files and directories currently installed.) Preparing to unpack .../nodejs_18.13.0-deb-1nodesource1_amd64.deb ... Unpacking nodejs (18.13.0-deb-1nodesource1) ... dpkg: error processing archive /var/cache/apt/archives/nodejs_18.13.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_18.13.0-deb-1nodesource1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)

got the latest node lts version working now using nvm to install the node
i follow this link to install nvm https://github.com/nvm-sh/nvm
and run
nvm install --lts # *installs the latest lts version*
nvm use --lts # *Use the latest lts version*
check node version to verify if node is installed
node -v

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!

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.

Ubuntu install PHP couchbase extension

I run composer install for new project and I got eror:
the requested PHP extension couchbase is missing from your system. To enable extensions, verify that they are enabled in your .ini files:
So I was trying to intall couchbase SDK from official website:
# Only needed during first-time setup:
wget http://packages.couchbase.com/releases/couchbase-release/couchbase-release-1.0-4-amd64.deb
sudo dpkg -i couchbase-release-1.0-4-amd64.deb
# Will install or upgrade packages
sudo apt-get update
sudo apt-get install libcouchbase-dev libcouchbase2-bin build-essential
after sudo dpkg -i couchbase-release-1.0-4-amd64.deb i got error:
(Reading database ... 155822 files and directories currently installed.)
Preparing to unpack couchbase-release-1.0-4-amd64.deb ...
Supported platforms are: Debian/wheezy,jessie and Ubuntu/lucid,precise,trusty,xenial
dpkg: error processing archive couchbase-release-1.0-4-amd64.deb (--install):
new couchbase-release package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
couchbase-release-1.0-4-amd64.deb
I use Ubuntu 18.04 LTS and PHP 7.1

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.

centOS can't install nodejs via yum

I was using node v0.10.x on my centOS server and I want to update node.js, so followed some articles. First removing currently installed:
# which node
# cd /usr
# rm -r bin/node bin/node-waf include/node lib/node lib/pkgconfig/nodejs.pc share/man/man1/node.1
and then check node -v is not working, good. But using yum doesn't install latest Node.js, so I searched some post and found this:
https://www.metachris.com/2015/10/how-to-install-nodejs-5-on-centos-and-ubuntu/
so I followed commands:
# rpm -Uvh https://rpm.nodesource.com/pub_5.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm
# yum install nodejs -y
and this is the problem. it prints numerous errors and keeps failing.
Resolving Dependencies
--> Running transaction check
---> Package nodejs.x86_64 0:0.10.42-4.el6 will be updated
--> Processing Dependency: nodejs(x86-64) = 0.10.42-4.el6 for package: nodejs-devel-0.10.42-4.el6.x86_64
---> Package nodejs.x86_64 0:5.11.1-1nodesource.el7.centos will be an update
--> Running transaction check
---> Package nodejs-devel.x86_64 0:0.10.42-4.el6 will be updated
---> Package nodejs-devel.x86_64 0:5.11.1-1nodesource.el7.centos will be an update
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
nodejs x86_64 5.11.1-1nodesource.el7.centos nodesource 8.7 M
Updating for dependencies:
nodejs-devel x86_64 5.11.1-1nodesource.el7.centos nodesource 7.6 M
Transaction Summary
================================================================================
Upgrade 1 Package (+1 Dependent package)
Total size: 16 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction check error:
file /usr/lib/node_modules/npm/node_modules/semver/package.json from install of nodejs-5.11.1-1nodesource.el7.centos.x86_64 conflicts with file from package nodejs-semver-2.1.0-1.el6.noarch
file /usr/lib/node_modules/npm/node_modules/semver/bin/semver from install of nodejs-5.11.1-1nodesource.el7.centos.x86_64 conflicts with file from package nodejs-semver-2.1.0-1.el6.noarch
file /usr/lib/node_modules/npm/node_modules/semver/semver.js from install of nodejs-5.11.1-1nodesource.el7.centos.x86_64 conflicts with file from package nodejs-semver-2.1.0-1.el6.noarch
... and keeps going on ...
Also before remove node, I also did this:
# npm cache clean -f
# npm install -g n
# n stable
but this isn't working at all, because always saying version 0.10.x, even downloaded latest one! ( I sawed 6.2.2 or something )
I think something messed up on my server and I don't know how to fix this. Can anyone gimme some advice? Also If can, I want to install latest Node.js.
Install Node from the EPEL Repository
yum update
yum install epel-release
yum install nodejs
node --version
To access npm to manage their Node packages.
yum install npm
The easiest way is to use nvm, the "Node Version Manager".
In a shell, do:
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
Note: If you want to understand the script before running it, read the docs on nvm github page and/or remove | bash from the curl command to read without running the .sh file
Close and re-open shell to use updated profile. Then:
//prints "nvm" if correctly installed
$ command -v nvm
// install latest version of node
$ nvm install node
//check it's installed correctly
$ node -v
v12.6.0
After failing with other methods, this one had no issues.
First, you must install epe-release
sudo yum install epel-release
After, you can install node.js and npm
sudo yum -y install nodejs npm
Its worked for me.
I spent a while on this on a Fedora 35 workstation (upgraded from Fedora 34),
$ yum repolist
nodesource Node.js Packages for Fedora Linux 34 - x86_64
it gave me
$ node --version v12.22.1
None up the installers made a difference until I found this explanation:
How To Install Node.js on Fedora 36/35/34
The tutorial includes 3 methods. It's the third one that worked for me.
Install Node.js on Fedora via NVM
First, install the NVM tool on your system by running the following command:
$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
Then, reload the system environment using this command. It will set the required environment variables to use nvm on the system.
$ source ~/.bashrc
$ nvm install v16.14
Downloading and installing node v16.14.2...
$ node --version
v16.14.2

Resources