I had started installing node using apt but couldn't install as I had some missing dependencies and after installing those missing dependencies then also had the same issue, so tried other ways to install nodejs.
Missing Dependencies on my install:
sid@sid:~$ sudo apt install nodejs npm
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
nodejs is already the newest version (12.22.9~dfsg-1ubuntu3.2).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libssl-dev : Depends: libssl3 (= 3.0.2-0ubuntu1.12) but 3.0.5-2ubuntu2.3 is to be installed
libuv1-dev : Depends: libuv1 (= 1.43.0-1) but 1.44.2-1 is to be installed
E: Unable to correct problems, you have held broken packages.
sid@sid:~$
- Using apt method --> This method didn't worked for me but you can definitely use this for installing node.
sudo apt install nodejs npm
- Using snap. If you are using a Linux distribution that already has snapd installed, such as Ubuntu or Debian based system, simply run:
sudo snap install node --classic --channel=20
channel is the version no can be changed as per you requirement
- Manual Install using the binary from the website:
Link to download: https://nodejs.org/en/download
Detailed Instruction for Manual Instruction
: https://github.com/nodejs/help/wiki/Installation
If you want build our own binary and then install, then follow this link
:
https://github.com/nodejs/node/blob/main/BUILDING.md#building-nodejs-on-supported-platforms
sid@sid:~$ node --version
v12.22.9
sid@sid:~$ npm -v
10.2.3
sid@sid:~$ yarn -v
1.22.19
sid@sid:~$ npm version
{
npm: '10.2.3',
node: '20.10.0',
acorn: '8.10.0',
ada: '2.7.2',
ares: '1.20.1',
base64: '0.5.0',
brotli: '1.0.9',
cjs_module_lexer: '1.2.2',
cldr: '43.1',
icu: '73.2',
llhttp: '8.1.1',
modules: '115',
napi: '9',
nghttp2: '1.57.0',
nghttp3: '0.7.0',
ngtcp2: '0.8.1',
openssl: '3.0.12+quic',
simdutf: '3.2.18',
tz: '2023c',
undici: '5.26.4',
unicode: '15.0',
uv: '1.46.0',
uvwasi: '0.0.19',
v8: '11.3.244.8-node.25',
zlib: '1.2.13.1-motley'
}
sid@sid:~$