Reputation: 276
nodejs -v
v12.22.9
I tried to upgrade
sudo apt remove nodejs
sudo apt install nodejs
I got error:
(Reading database ... 220599 files and directories currently installed.)
Preparing to unpack .../nodejs_21.6.1-1nodesource1_amd64.deb ...
Unpacking nodejs (21.6.1-1nodesource1) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_21.6.1-1nodesource1_amd64.deb (--unpack):
trying to overwrite '/usr/include/node/common.gypi', which is also in package libnode-dev 12.22.9~dfsg-1ubuntu3.3
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_21.6.1-1nodesource1_amd64.deb
How can I resolve that so I can upgrade my nodejs?
Upvotes: -2
Views: 304
Reputation: 1
Installing Node.js Using NVM (Node Version Manager)
NVM is a script-based version manager for Node.js, allowing you to install and manage multiple active Node.js versions. To install NVM, use the following commands:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
After installing NVM, you can install the latest version of Node.js with:
nvm install node
Verify the installation with:
node -v
Upvotes: 0
Reputation: 199
You can use https://github.com/tj/n to install and manage nodejs version. You can install using curl:
curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s lts
and then you can do:
n latest
This will install the latest version. for specific version you can run:
n <version_number>
Upvotes: 1