Updated NPM but still showing as old version - node.js

Getting "npm: command not found" on this computer. Only way I knew to get it was by uninstalling node with Homebrew and reinstalling from the node.js site. Just reinstalled node.js on this computer and have npm version 2.5.1 with it.
I went to update to the newest (2.7.1) using:
sudo npm install npm -g
Updated without any errors, but running npm -v tells me I'm still on version 2.5.1
In the process of looking into the issue, see that old npm related files are on this computer. Old Changelog last modified 30 days ago exists saying "v2.7.1 (2015-03-05)" so npm was updated and on here at one point.
Can anyone point me in the right direction to figure out what is going wrong?

Making some assumptions here: there isn't anything really wrong, there just might be some installation issues. Homebrew should be just fine for installing node, Thoughtbot uses it to set-up laptops (see here).
To make sure Node/NPM installation is done in a smooth way, I did this:
sudo chown -R $USER /usr/local
Per this post.
I am on Yosemite and I haven't had any issues using this set-up, especially when updating NPM (did it when I read your question).

Related

NPM is really slow performing simple tasks

Everything I do with NPM takes several minutes; especially npm install, even if I already have all the packages installed. I first thought the problem is that the old code I am working with just takes longer to update (because last time an older npm version was used) but the problem percists even if I repeat the process.
My system and other Information:
Windows 11 PC
Ubuntu 18.04.5 VM from the Microsoft Store
VS Code.
npm version 8.19.2
node version 16.17.0
From my package-lock.json file: "lockfileVersion": 2
I usally have 5 to 10 dependecies listed in my package file
My internet speed is around 25 MB/s
What I tried so far with no luck:
A newer Version of Ubuntu
Using http instead of https a la:
npm config set registry http://registry.npmjs.org/ --global
as was suggested in 'npm install' extremely slow on Windows.
It seems to me it still tries to connect to the https address (at least that's what it looks like if I use npm install --verbose to show more feedback).
Reinstalling Node and NPM through other means as it was suggested in Why is "npm install" really slow?
No matter what I still sit here, wasting ages waiting for my npm install.
I finaly found a solution. I just did not now to ask the right question.
The problem was that I was using WSL version 2 and my files are in C: and not the Ubuntu folders. A fix that worked for me was moving to WSL version 1.
More details can be found here.
If you're also switching to WSL version 1 and are having problems with node or npm, this might help.

cannot uninstall node and npm completely on high sierra

I recently installed Node on my MacBook running High Sierra 10.13 using the .pkg file supplied on their website.
After a few hours of experimenting with installing other packages and writing scripts, I decided I would like to uninstall both Node and NPM to get a fresh start.
I tried all of the top answers from this thread, but to my dismay, after having followed all instructions, and repeated all steps many times, terminal would still recognise the Node and NPM versions.
I ended up running a bash script through terminal which I found on the same thread, which ended up doing nothing but downgrading my current version of Node to 0.10.8 - making it a lot more difficult to delete in the long run.
I've re-done all of the steps from the aforementioned thread with no avail, and terminal still stating that it has version 0.10.8 (and NPM just completely not working at all)
Currently at my last stance of what to do, so hopefully someone on here can help me with my problem.
Cheers.
After searching through Google and StackOverflow for hours, I finally came up with a solution to the problem on my own.
Running the type command within terminal against node, I got this returned:
:~ myusername$ type node
node is /Users/myusername/.nvm/v0.10.48/bin/node
Subsequently, after deleting that folder, Node appears to be completely removed from my system.
I have since made sure that I have deleted all node and node_module folders that I could find within /usr/ to make sure - and I would suggest that anyone attempting this also do the same.
Try to run the following command
brew uninstall node
After the above command, you need to scan manually for node_modules if exists. Try following.
grep -irl "node_modules/node"
sudo rm -rf result_from_above_command
rm -rf ~/.npm
I hope this will remove all the node and it's components. As I have done like this, once before.
Thank you.

Global installation with npm doesn't work after Mac OS X Mavericks update

After upgrading to OS X 10.9 Mavericks, node wasn't found anymore in bash. I think I installed it with brew a while ago.
I decided to use the installer from node.js website. It went fine and both node and npm became available in bash. However, installing packages globally doesn't work.
The npm -g bin outputs following path /usr/local/bin.
However, after running npm install -g karma and invoking ls -la /usr/local/bin I can't see a symlink to the path where karma executable resides.
Running npm -g root returns /usr/local/lib/node_modules and after the installation I can see that karma module is there.
Not sure what I else I could check. Thanks!
I found that the root cause of all of my npm install issues was the missing Xcode license agreement.
After the Maverick update, XCode upgraded as well and if you don't launch XCode, the license agreement will be missing.
Once I accepted the agreement, installs were successful.
I had the same problem due to not accepting the xcode license after upgrading to Mavericks. I was able to accept the new xcode license by running the following:
sudo xcodebuild -license
However, npm still was not working because symlink was not created, but trying to reinstall said npm was already there. I went ahead and:
brew remove npm
and then reinstalled with:
brew install npm
and I am back working again. Not a big fan of the reinstall, but I think the need to accept the xcode license left things in a hung state.
I had the same problem - npm did not work after upgrading to mavericks. I tried all the above steps, but was still stuck. Specifically, when I tried to re-install node,
I got the error:
Warning: The post-install step did not complete successfully
You can try again using brew postinstall node
But running brew postinstall node responded:
Error: Permission denied - /usr/local/lib/node_modules/npm/AUTHORS
I tried removing all the node modules previously installed
sudo rm -rf /usr/local/lib/node_modules/
and then uninstalling and reinstalling node
and that finally got both node and npm working as before.
The problem seems to have occured because I tried to install packages that were previously on my system. The symlinks weren't created, probably because of that. Once I removed the packages and re-installed them (or tried to install packages I haven't had), they were added to /usr/local/bin as symlinks.
I had the same problem. After a maverick upgrade npm was not working, yet node itself was. I was not using the latest version as our team prefers to use 0.8.10.
In any case nvm, the node.js version manager, was still working. In this case I just reinstalled:
$ nvm install 0.8.21
######################################################################## 100.0%
Now using node v0.8.21
$ npm
Usage: npm <command>
where <command> is one of:
add-user, adduser, apihelp, author, bin, bugs, c, cache,
completion, config, ddp, dedupe, deprecate, docs, edit,
explore, faq, find, find-dupes, get, help, help-search,
home, i, info, init, install, isntall, issues, la, link,
list, ll, ln, login, ls, outdated, owner, pack, prefix,
prune, publish, r, rb, rebuild, remove, restart, rm, root,
run-script, s, se, search, set, show, shrinkwrap, star,
stars, start, stop, submodule, tag, test, tst, un,
uninstall, unlink, unpublish, unstar, up, update, version,
view, whoami
npm <cmd> -h quick help on <cmd>
npm -l display full usage info
npm faq commonly asked questions
npm help <term> search for help on <term>
npm help npm involved overview
In the case where nvm was not working you might need to reinstall that, as well- ymmv
I am not sure if my answer was too late or not. I found myself in a difference situation than you. Hope that my experience an hour ago helps you.
my npm version (npm -v) is 1.4.28. First, I installed node.js on a computer with an administrator account. Then I created a user with administrator rights. When I tried to check the version of npm running, I failed to do so.
I searched the web and came across with this text. The original poster asked to check the path settings. I did not have node.js and npm installed with homebrew, another software that made me headache two months ago. I checked that I can run node. It is because node is located at /usr/local/bin, where all users have rights to execute programs. But for npm, it is in fact a link to ../lib/node_modules/npm/bin. However, the /usr/local/lib folder is not accessible by other users' but the administrator's account only.
I "sudo -i" and granted "chmod a+x ../lib" to it. Surprisingly, all folders' within have the correct execution right. I suspected that is some sorts of bug. I exited sudo and tried "npm -v" again. Succeed.
Hope that helps.
In case the other solutions posted here do not work for you either, you may try out the approach suggested on this GitHub page. With a complete re-installation according to the insturctions on the page, I finally got npm (and an application, vs-mda-remote to be precise) working.
EDIT: This happened after updating from Mavericks to Yosemite.

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....

Problem installing socket.io on Fedora Core

I'm trying to install socket.io on my machine, but I keep encountering errors when I run npm install socket.io as directed on their website. I'm not sure if I have version incompatibilities for npm or node.js or if I'm simply missing something obvious. As far as I can tell, I have the most recent stable version of both of them.
When I run the install command, the console outputs 40+ errors, and at the end I am given the line npm not ok. Any ideas as to what is going wrong?
What is the error?
Are you installing npm using code from git? I can only guess that you are not using a stable code, because the master branch from git is often unstable.
If that is the case, what you can do is to get the latest code from the git repository and install it again.
$ cd npm
$ git pull
$ make install
Hope it will solved your problem.
You need to provide an error log if you want anyone to try and troubleshoot your problem. It would also be helpful to know whether you installed Node and NPM from source or RPM. Furthermore, if you installed from source, did you do a standard install or did you make customisations?
If you are able to start from scratch, I suggest following the steps below and seeing how you go. Installing into your home directory won't require root and it makes it easier to clear everything out if you need to start again.
Install the stable release of Node in your home directory (use ./configure --prefix=~/Node/)
Set your path as appropriate (ie. PATH=/home/user/Node/bin:$PATH)
Run the standard NPM installer (curl http://npmjs.org/install.sh | sh)

Resources