The Node.js v10.19.0
Conundrum
"I am going to answer this question in reference to Ubuntu, because I know about the apt
package maintainer, and I feel that even if you don't use Ubuntu as your distro, so long as your a Linux user, you have still used apt
/apt-get
."
This question demonstrates the method used by NVM for installing Node on a platform like Linux.
NVM makes it extremely easy to install node. Not to long ago everyone had to use curl/wget & npm...
Honestly I can't remember all the steps, but it seemed very involved for an open source language that is extreamly popular, and heavily used on all platforms, henceforth; NVM came about, and grew fast in popularity.
The Problem with NVM
The problem with NVM is the same thing that makes it so damn useful — "to be clear I do really love the Node Version Manager" — NVM uses environment variables, and local installation folders to isntall node, and to configure the environment to use the NVM and NODE commands. The problem is you already have the apt
package-maintainer's version. _Apt software is always behind the most current released version, and this is true for almost all software that we could discuss in relation to apt
. Your Debian Linux "Out-of-the-Box" install, comes with the latest apt
version of node, which is
(at the time of authoring this answer):
Node.js v(10.19.00)
...and It gets installed, and assigned to the path variables in the system root binary directory @...
/usr/bin
If you are experiencing this issue, you should do a couple things to gather some info. First, go to your console, and type in the command which node
.
Here's a snippet that shows the commands you want to type that'll help you troubleshoot the issue:
# First type the command like this:
~$> which node
# Then do it like this:
~$> which -a node
Your Output should look somewhat like this:

!IMPORTANT!: Also use the command node --version
or node -v
so you know what your shell thinks your current version is. Its important to know what your shell is doing.
The first which
command shows what node installation is being used when you use the command ~$> node
, the second which -a
command, shows you all of the executable node programs you have throughout your system. You will see multiple, and this is why when you try using npm
or other software with nod version is used when you use the command
the next thing you want to do is type the following command
~$> nvm which current

Most every thing should be pointing to a node install located on your path, with a pathname that looks close to something like this:
/home/<your-user-name>/.nvm/versions/node/<current-node-version>
The problem is if you try to do something, like install vsce
the extension packager for VSCode with npm, it wont install, even though node seems to be working fine.
So what you have to do is remove the other version of node you have, that you probably seen while executing the commands above. Currently /usr/bin/
has nodejs
which is node, and it is the version of node we talked about which is: `node v10.19.00.
Removing the unwanted Node Package & Fixing NPN:
The last thing we will do before removing the unwanted nodejs package is doctor up npm
. Use the two commands below, but just read what the output says. It will likely show unpleasant errors, and may not work at all, but just type them in, so we can use them in a bit to fix npm w/ the new node.js version, and you can see the difference. This will help demonstrate, under the hood, everything your doing, and how it is affecting the software on your machine.
okay go ahead and execute away:
~$> npm doctor
then use
~$> sudo npm doctor
Now We Will Remove the Un-wanted package: "Node v10.19.00"
First, lets look at your packages.
To do that use the command below to view your packages. Look and confirm that nodejs is in the list
~$> dpkg --list
then use..
sudo apt-get --purge remove nodejs; sudo apt-get autoremove;
# OR alternatively you could do it in two commands:
sudo apt --purge remove nodejs
sudo apt --purge autoremove
Now use...
~$> dpkg --list
...to confirm that nodejs is indeed gone.
With the unwanted node package out of the way, lets run the following again:
You will likely get unhappy results again, but thats okay, you should notice a bit of a change in behavior from the npm doctor
though.
~$> npm doctor
then use
~$> sudo npm doctor
---
The output probably looks like this:

Now you need to copy your NVM version of Node.js (currently I am using Node v17.1.0
but by the time you read this, you will likley be using another version.
To copy your _NVM Node.js Executable to the correct directory, you must do the following:
- Use the
nvm which current
command again, and if you remember, it will print the name of a Node executable
that looks like this:
/home/<your-user-name>/.nvm/versions/node/<current-node-version>
Copy & Paste the <NODE-PATHNAME>
the Node executable that was logged into your console.
Execute the following command:
~$> sudo copy -v <NODE-PATHNAME> /usr/bin
Now if you don't have the following directories create them:
~$> mkdir ~/node_modules
~$> mkdir ~/node_modules/.bin
!NOTE:
Now upgrade npm. Unlike Node, we won't use an installed package from NPM, and copy it to the places where we want it. We will just makesure both locations have the same npm version
Just FYI, NPM is having the same issue as node.js, but you may have figured that out already.
Use the following commands:
The first npm install will be executed as seen in the snippet
~$> nvm install-latest-npm
The second npm install (the one just below this text) needs a little adjustment, after npm@
you have to replace the word latest
with the most recent version of npm.
~$> npm install -g npm@latest
Now lastly you need to use the npm doctor to make sure every thing is working:
~$> npm doctor
~$> sudo npm doctor
You should get a result that looks like this:
