I think I've done a Very Bad Thing and removed the path to my npm install somewhere. I vaguely remember running rm -rf usr/bin/local/npm (approximately) during an install of something else (my main goal is updating node and npm) and I think I ran into an error with that file so I deleted it. Probably stupid, yes, and I should learn what's happening in my computer before I mess with it. Anywho, I think that deleted npm (or the path to it) so I tried following these instructions to reinstall node and npm on my system. However, I still think the path is broken.
When I run node, I can run node in my terminal.
When I run node -v I get v8.4.0
When I run whereis node I don't get any output.
When I run which node, I get /usr/local/bin/node
But anytime I try to run npm <anything> I get the error:
-bash: npm: command not found
The last line of the resource I used curl -L https://www.npmjs.com/install.sh | sh I believe should install npm, but something is still broken.
Any help would be extraordinarily appreciated. I'll never do it again I promise. Thank you in advance.
It looks like the command line processes for installing NPM would not fix this problem, so I just ran over to npmjs.org and downloaded the stable version. That seemed to fix it.
Related
When I do find . -name "node*" from my root directory, I get:
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node_exporter.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/nodeenv.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node-sass.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#14.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#10.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/nodebrew.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#12.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/nodenv.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#16.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node-build.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/node#18.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/nodejs
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/node#19
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Aliases/node.js
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks/nodeclipse.rb
./usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask/Casks/nodebox.rb
./usr/local/Homebrew/Library/Homebrew/rubocops/cask/extend/node.rb
./usr/local/Homebrew/Library/Homebrew/test/language/node_spec.rb
./usr/local/Homebrew/Library/Homebrew/language/node.rb
but brew ls doesn't show node and node -v and npm show that the commands are not installed on PATH? What's going on here?
I went through the process of
I went through the process of removing all traces of Node and npm from my own installation as npm was corrupted (was mishandling vulnerabilities), and now want to install it using brew, or in some other way so all the errors with npm when attempting to npm install don't occur. Why does brew have node installed even though I didn't install it?
Those files are not NodeJS itself, but are the instructions that tell Homebrew how to install NodeJS. You can remove those formula (along with any others that are not being used) with brew cleanup.
Edit: You cannot actually remove the formulae since those are needed if you were to install it at a later point.
Recently I was trying to add a new dependency to my project using npm, but when I ran npm install, nothing happened. It just returned me straight back to the command line. I tried a few more npm commands like npm -v, but none of them did anything and all of them returned me back to the command line. I tried using sudo apt --reinstall install npm, didn't fix it. I tried to remove and install using sudo apt --purge remove npm, still didn't fix. I also tried uninstalling nodejs as well, but none of these things did anything to fix the issue. All npm commands just return back to the command line and do nothing, not even "command not found." One strange thing I did notice happening was that even when I restarted after uninstalling node and npm, node -v still gave the version of node I had installed. Does anyone have any idea what's going on here? (Operating system is Ubuntu 18.04)
The issue stems from the fact that my active node version was installed using n and not sudo apt install, and for whatever reason, they are in separate locations and don't like to cooperate. This led to me messing around with the PATH variable, and eventually figuring how to get the node and npm from n to uninstall. Then I just reinstalled using n and everything worked fine.
On MacOS:
I'm unable to execute any npm package command. Every time I try, I see command not found. Like so:
-bash: live-server: command not found
I've installed node.js directly from the website.
https://nodejs.org/en/download/
I've installed live-server globally, and locally. It appears to work. When I try the command, it fails.
I've removed node.js and npm, re-installed and still fail to execute a command. I'm quite stumped. I've reviewed similar posts, implemented the suggested solutions and still can't manage to execute any npm command.
Several of the posts I've reviewed:
sudo: npm: command not found
NPM Command Not Found After Installing Node
What should I do next?
Are you using Windows?
Did you check if NPM is in Path on "Environments variable"
My bash_profile file had the wrong data saved. Correcting the file solved the problem.
I have just installed node and NPM using homebrew, and before that with the package downloaded from the Nodejs website and I still cannot use npm at all without prefixing it with sudo.
When I try npm -v for example, no error is shown, my terminal just waits and waits and waits until finally, a [Process completed] message appears. Why is this and how do I fix it?
I have searched around and tried many things, including the advice in this SO post
Have you added your homebrew location to "$PATH" by adding "export PATH="/usr/local/bin:$PATH" to your bash profile?
The simplest solution I found to make it work for me is to use nvm instead.
https://github.com/creationix/nvm
You probably don't need, or want the feature given by nvm (Switching between Node.js versions) but it is meant to be use in user land and doesn't require access to /usr/lib or the like.
And therefore will provide you what you need without any weird hack.
With Aurelien Thierot's help, I figured out what the issue was: my dotfiles had an npm() function that I created to ease installation of npm packages, this had overridden npm itself.
For those that are interested, my fixed npm function for installing packages is:
function npmi() {
npm install --save-dev "$#"
}
Problem
I recently updated to the latest version of node which is supposed to come with npm pre-installed. Although all the files are there, when I try to call something like npm help in node I get a hanging .... If I try to run it directly from command prompt I get this error:
Any Idea on what the possible issue could be? I am running on windows 7 btw.
Ideas
Pathing issues?
Conflict with previous installation?
Should I just install manually rather than the executable?
Thanks in advance for your help!
Don't call npm with node, if you want to see if npm is installed properly (and is in your path) execute the following command in the terminal:
npm -v
If you want to install a module: npm install express