Problems with Node npm on Ubuntu 12.04 - node.js

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.

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 not compatible with node v12.5 on ubuntu 16.04

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

ERROR: npm is known not to run on Node.js v

Every time I open a terminal window, I get this (even before typing anything):
ERROR: npm is known not to run on Node.js v4.1.2
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/
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v4.1.2 --silent` to unset it.
I was never running a version of node 4, but anyway I deleted node.js completely following some pretty thorough steps I found online, and then reinstalled it from the website to version 8.11.2 (node -v gives me v8.11.2) but the warning still appears
I never paid it much attention until my npm started seriously acting up while trying to work with create-react, giving me tons of security warning with npm audit and not letting me update to the indicated versions of modules.
I've tried everything, reinstalling npm, reinstalling node, etc. and I'm worried that it's interfering with my app now.
(nvm maintainer here)
If you can get node working such that nvm current doesn't say "none" or "system", then you can run nvm install-latest-npm to ensure you have the latest version of npm that actually works on your node version.
Separately, node 4.1.2 is EOL - if that's your system version, you may want to uninstall it completely.
If you're still having trouble, please file an issue on http://nvm.sh

Global npm installs break after restarting terminal

I recently installed node using nvm and had no problems initially with installing globally packages with npm. But then I found that if I close the terminal in which I originally installed the package, I will get "command not found" when attempting to use it.
For example, browser-sync. I closed the terminal after finding that it worked properly. When I opened it up later to continue working on the project I need it for, it turns out that now I get "command not found" in every directory despite installing it globally.
I am running Linux Mint Cinammon 17.3 with the latest version of node and npm.
Any help for this?
I've since solved this problem by:
Completely uninstalling nvm and node.
Reinstalling node using apt-get
Changing npm config prefix to /usr/local
Correctly setting npm permissions
For some reason despite multiple uninstalls/reinstalls and playing with permissions before, it wouldn't work until I deleted all the folders created by node or npm before reinstallment. Weird.

npm comes with node now. What does this mean?

Node noob here.
I had previously installed both npm and node separately.
Apparently, npm comes with node now. (link)
To my newbie mind, this means my previous dual installation is old and ugly. 1 binary > 2 binaries. So i uninstalled both.
Then I installed the latest node following the procedure. (i am running eOS)
Terminal
user#box:-$ which node
/usr/bin/node
user#box:-$ node -v
v0.10.22
user#box:-$ which npm
user#box:-$ npm -v
bash: /usr/bin/npm: No such file or directory
I can always run:
curl https://npmjs.org/install.sh | sh
but that seems to indicate that npm is actually NOT included in node.
When they say they are included do they just mean the code is in the same repo, but the binaries are still different?
Final question I have /usr/bin/node as well as /usr/bin/nodejs
can i delete one of these? im not sure when/where i picked up a second copy.
Yes, the nodejs package includes both node and npm executables. The code for each has its own repo, but when packaged both are included.
npm source: https://github.com/isaacs/npm
node source: https://github.com/joyent/node
When you install that .deb file from the PPA, you should get both /usr/bin/nodejs and /usr/bin/npm and 2 symlinks at /usr/bin/node (which points to) /etc/alternatives/node (which points to /usr/bin/nodejs).
If any of this isn't true, your install didn't fully succeed, most likely due to conflicting files you left around from your manual install. I would suggest uninstalling the .deb then making sure there are no stale files left from your manual install and then installing again.
Only node.js packages comes with npm. so if you are installing using an .msi, .exe, .dmg .pkg, .deb or using a package installer like apt-get, yum or brew, then you'll have both node and npm.
However,npm is not part of the node core. if you are installing node and using a method where you are using ./configure or make install || make link, then npm will not be installed, and will need to be compiled using the same type of installation, and node will have to be placed on your path.
If you used git, or unzipped node and you can see a configure script, then you will also need to acquire npm.
I've had issues (mostly on Mac) with npm ending up in directories that aren't in the terminal PATH. If you can figure out where npm is located, you can just add it to your path with something like:
export PATH=$PATH:/path/to/npm
I think (I'm not on a mac so I can't check at the moment) that it sometimes gets put in /usr/local/share/. But at any rate, the problem is likely NOT that npm isn't installed, but that it's installed somewhere you're not expecting.
Few months ago i had started learning the react so all this stuff i needed to install my laptop that had the ubuntu operating system.
What i did -- First i installed the node and without knowing that it came up with the npm package. I installed the npm package again.. but there was no conflict at all.
But after exploring all these things that nodejs have npm package. So i uninstalled the npm package due to concern about memory usage..
And Now everything is working fine....

Resources