npm not compatible with node v12.5 on ubuntu 16.04 - node.js

I tried updating to v12.5. I was using node version 8 before this. When I installed node v12.5 npm stopped working.
Whenever i try installing any package with npm. It shows this error.
I tried deleting node through different sources. But, it did not work.
I also tried reading different articles like these
https://tecadmin.net/install-latest-nodejs-npm-on-ubuntu/
https://websiteforstudents.com/install-the-latest-node-js-and-nmp-packages-on-ubuntu-16-04-18-04-lts/
https://www.rosehosting.com/blog/how-to-install-node-js-on-ubuntu-16-04/
I almost tried all the sources available on web.
I tried
sudo apt purge node
sudo apt autoremove
and some similar commands. But, it did not work.
Whenever i type node -v. it still shows me 12.5
and when i type npm -v. it shows me 5.5.1.
How do i either remove node completely?
or
install specific version of node?
or upgrade npm to version 8.x
How do I solve the problem?
I cannot even install anything, it shows this error even after installing some other packages.
how do i solve it?
EDIT:
I found the solution...
its basically using nvm to install different versions of node in your machine.
and setting default version for your machine using nvm

Related

Why is there a nodejs directory in ubuntu subsysem when nodejs is not installed?

I just installed the ubuntu subsystem.
I have not installed node yet but it has a nodejs directoy under /mnt/c/Program files/nodejs.
The problem is that I can run npm after installing node. It gives me this error:
I uninstalled and reinstalled the linux subsystem, but the directroy is always there. I tried all of the solutions online for dealing with this error but none of them worked.
I can't even remove this directroy because of permissions. Even sudo-ing won't work.
How can i fix this and get npm running?
The folder you’re browsing to is actually your Windows installed Node version.
You’re better off installing nvm or just using nodesource to download and install Node.
NVM is my preference if you’re needing to install multiple versions for dev purposes etc. nvm

npm is not compatible with Node.js

I had node installed in my machine and everything was working fine. During an online course made in 2019, the instructor was using an earlier version of npm (v5.5.1) and advised everyone to use the same version with him for follow up reasons. So I downgraded to v5.5.1 but now I keep getting one same error (incompatibility) for almost all commands. I read some solutions to similar problems here and even tried extra steps but the problem still persists.
I uninstalled node from my system, restarted the system and reinstalled node but the version of npm still remained v5.5.1.
I tried to uninstall npm from the command line npm uninstall -g npm but it threw incompatibility error.
I searched the web for compatible version of node.js for npm v5.5.1 and got node v10.15.1 which I downloaded installed with several system restarts but my node and npm still remain incompatible. Please what can I do?
You should use nvm which is the Node Version Manager, cURL:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
commands:
nvm install <version> Download and install a <version>
nvm use <version> Modify PATH to use <version>
nvm ls List versions (installed versions are blue)
Helpful reads:
How can the default node version be set using NVM?
How to change node version with nvm

I want to install and run react-create-app on Ubuntu 20.04

Snap of the error
I tried the command sudo npx create-react-app my-app. It gives Node error regarding version even after I downgraded Node to LTS
I tried to downgrade Node, upgrade NPM, even clear cache of NPM. It still messes up at the Installation.
Please help me out.
Thanks.
Edit:
The versions I'm using are as follows:
Node: v14.15.1
NPM 6.14.9
and running it without sudo still gives the same error.

nodejs 4.2.6 not getting updated to latest version

I installed Node and npm as they are required to install angular cli.
Now, if I type this command:
npm install -g angular-cli
I get this message in terminal:
ERROR: npm is known not to run on Node.js v4.2.6 Node.js 4 is supported but the specific version you're running has a bug known to break npm. Please update to at least 4.7.0 to use this version of npm. You can find the latest release of Node.js at https://nodejs.org/
I also followed this link, but still the issue is not resolved.
I tried removing node, npm and then reinstalling, updating node according to all the ways I found on internet, but still the version(4.2.6) is same.
I don't understand what I am doing wrong as I am new to Linux.
Surprisingly, npm is quite complicated in Linux, until you discover Node Version Manager which allows you to easily install new versions and swap between them.
After installing nvm, you can install any node version with nvm install <VERSION_NUMBER> and you can set it as default with nvm alias default <VERSION_NUMBER>
You can swap between versions using nvm use <VERSION_NUMBER>

Problems with Node npm on Ubuntu 12.04

I downloaded node a week ago and it was running fine, except today I realized that the version was far outdated. I tried to uninstall node and npm manually by deleting files (read a different stackoverflow question), but node still runs as well as npm.
How do I successfully uninstall both of them and install the correct versions of them?
You could type
which node
in your terminal to see where node is installed. Same with npm. Remove those files.
I really like installing node using nvm.

Resources