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.
Related
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
I can't install node/npm with either nvm or apt get install (wsl2 ubuntu). Here is what I tried first
$ code export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist
$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
It installed nvm but when I did nvm ls I only got this (no versions listed)
-> system
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
So I did ~/.nvm and tried apt-get install -y nodejs which seemed to work ...
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
npm
The following NEW packages will be installed:
nodejs
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 0 B/122 kB of archives.
After this operation, 932 kB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ... 40014 files and directories currently installed.)
Preparing to unpack .../nodejs_12.22.9~dfsg-1ubuntu3_amd64.deb ...
Unpacking nodejs (12.22.9~dfsg-1ubuntu3) ...
Setting up nodejs (12.22.9~dfsg-1ubuntu3) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for man-db (2.10.2-1) ...
Scanning processes...
Scanning candidates...
Scanning processor microcode...
Scanning linux images...
Failed to retrieve available kernel versions.
Failed to check for processor microcode upgrades.
No services need to be restarted.
No containers need to be restarted.
User sessions running outdated binaries:
root # /dev/pts/0: bash[9754,9845], sh[10875]
root # /dev/tty1: init[9752], wsltermd[9753]
root # /dev/tty2: bash[25], init[24]
No VM guests are running outdated hypervisor (qemu) binaries on this host.
Then I did node -v ...
bash: /usr/bin/node: cannot execute binary file: Exec format error
I am running on a brand new windows machine with win10 home. I installed wsl2/ubuntu-22.04 and have been using it with no problem. So everything is fresh. I am not behind any proxy.
I am pulling my hair out. Can someone help me?
EDIT: I did apt install nodejs npm from a vscode wsl terminal and got a very long install which seemed successful. Now when I run npm i -g vite I get ...
/usr/bin/node: 1: ELF: not found
/usr/bin/node: 2: : not found
/usr/bin/node: 4: Syntax error: Unterminated quoted string
so I'm losing even more hair. By the way, I've been following The IT Crowd advice and rebooting often.
I got node/npm installed by reverting to ubuntu 18.04, installing nvm, and doing nvm install 'lts/*'.
nvm ls still doesn't give any results so I'm surprised the install worked. It's also a pain that I can't list the node versions.
installed node.js already but shows
Command nodejs not found, but can be installed with:
sudo apt install nodejs
then tried, sudo apt install nodejs
and shows
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version (14.13.1-deb-1nodesource1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
but when I try to check node.js version, $ nodejs -v
it shows, Command nodejs not found, but can be installed with:
sudo apt install nodejs
Please help me to solve this error and properly see node.js version
The nodejs executable is called node, please run node --version to see if your installation works.
I moved from windows to ubuntu and following the instruction as per the site - https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
Following comand ran successfully
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
Then
sudo apt-get install -y nodejs
The output of the above command is :
$sudo apt-get install -y nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version (4.2.6~dfsg-1ubuntu4.1).
0 upgraded, 0 newly installed, 0 to remove and 519 not upgraded.
As you can see its taking nodejs of version 4 , although I trying to install 8+
I removed the nodejs with
sudo apt-get remove nodejs
but still on trying again it says the same thing.
Please note that the setup is new and there was nothing installed previously
I am not sure but I wanted 'node', why its trying to install nodejs
If I try to do this -
$ sudo apt-get install node
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package node is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'node' has no installation candidate
Hey I use Ubuntu 16 the latest LTS
What you can do, is install ubuntu-make
Then run
umake nodejs
It installs the latest version available (v8.2.1)
Or, you can also use nvm
The detailed instructions are here
Note If you use ubuntu-make , you may have to log out and log in
Then check your version via node -v
Once you have version 4, you can update it to the latest. See this topic Upgrading Node.js to latest version
I have this odd problem that when I try to install NodeJS on a fresh Ubuntu Server VM.
I execute the two simple steps from the official instruction but somehow I manage to fail.
In the home directory of my user I execute curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - which ends successfully and then sudo apt-get install -y nodejs but this results in the installation of v.4.2.6.
Output can be seen below:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3161 kB of archives.
After this operation, 13,2 MB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ... 97187 files and directories currently installed.)
Preparing to unpack .../nodejs_4.2.6~dfsg-1ubuntu4.1_amd64.deb ...
Unpacking nodejs (4.2.6~dfsg-1ubuntu4.1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up nodejs (4.2.6~dfsg-1ubuntu4.1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Please help.
You probably have to run sudo apt-get update before sudo apt-get install to update the local package lists after adding the sources for 6.x. If you do that, you should see version 6 being installed.
The answer was hiding in this thread: Installing NodeJS on Ubuntu Trusty
So it must have been some kind of an issue with curl using the local network so I used wget to download like this:
wget https://deb.nodesource.com/setup_6.x
And then from the same directory:
sudo bash ./setup_6.x
And finally:
sudo apt-get install nodejs
Which did it.
You might consider using nvm to install Node instead of the distro package. This offers you more flexibility in managing your version of Node.