Hoping you can help me figure out this issue!
I just bought a new MacBook and was getting my development environment set up today. I installed XCode, Brew, NVM, and Git. When I installed Git, I had to change it so it was the first in the path so I could avoid using Apple Git, and I think that severely messed things up.
For some reason, nvm was not showing when I was running:
nvm ls or nvm ls-remote
Yet when I told brew to install nvm, it said it was already installed. OK. Eventually was able to get it sorted out and install node and such.
Fast forward to now, I went to run node in the terminal. Node was not found. Did some research and found that I should not install nvm with homebrew, so I did brew uninstall nvm and brew cleanup and then installed through the recommend github repository.
I ran the necessary commands and added to my PATH, and when I ran command -v nvm, nvm was returned. GREAT. Then I ran the other commands to install Node and I was able to use it, until I closed the terminal.
Now when I reopen the terminal and run node, it returns command not found. Command -v nvm does not return anything too.
Please help - it's been such a headache and I can't seem to figure out whats going on. Every solution I'm finding on Stack Overflow works until I close the terminal.
I was able to figure it out. The command all NVM guides tell you to run in order to start running node was not properly added to .bashrc.
Use these as a reference if you have the same issue as me:
https://itnext.io/nvm-the-easiest-way-to-switch-node-js-environments-on-your-machine-in-a-flash-17babb7d5f1b
.bashrc: Permission denied
Related
I am using macOS Big Sur and want to update my Node. However, after downloading its file from the official website and completing its installation, my terminal still shows and uses my previous node version.
Does anyone know how can I overcome this issue?
Thanks
terminal screenshot
I suggest using nvm. It's much simpler and eradicates the headache of updating.
nvm
To do this, you can install nvm. https://github.com/nvm-sh/nvm#installing-and-updating
you will be pasting in the curl command curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Note: when this is finished running, you should see a line near the bottom which says something like export NVM_DIR="$HOME/.nvm"
Copy and paste this and hit enter.
Then check to make sure you have nvm installed now nvm -v
Nodejs update
After, in the terminal, type: nvm install node (you can also check your current version first with node -v
Run it and then check node version again. It should be updated.
npm
While you're at it, you can also update npm.
Check version npm -v
Update npm install -g npm
This should do it. Let me know if there are any issues. Note: this can all be done in the -zsh shell, no reason to move back to bash.
The error displayed was sudo: n: command not found, which hinted that the binary might have not been successfully installed on your system. You need to check the location of n executable by using which command:
$ which n
Reinstalling n with more verbose debug level may also provide you with better information for troubleshooting.
$ sudo npm install --loglevel verbose -g n
Among possible options to install Node.js on MacOS, n was tested to be less error prone as you can read here. You should be on the right direction with the package manager choice.
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.
The story:
I had installed n about a month back while playing around with creating an Eslint config on my Mac, which was when Sublime Text started giving me problems, specifically with Eslint via Sublime linter. I had a bit of a break so I didn't attempt to fix the issue until last week, which was when I uninstalled n and installed nvm thinking that the issue was n. I then started getting the cannot find node error when I save any file in Sublime. Since then I had uninstalled nvm and node.js in hopes to start from scratch and fix the issue. I re-installed nvm and found this post, stating the issues that nvm creates with changing the path for node.js on my machine. I tried the fix that was given, which was to create a link between the nvm path to node and usr/local/bin/node but that didn't work either. I have since uninstalled nvm in hopes that just having good old node.js installed by itself to do the trick. Still no luck.
The error:
Couldn't find Node.js. Make sure it's in your $PATH by running node -v in your command-line.
Which is an alert from the Sublime app that only happens when I try to save a file.
Other things I have tried:
Updating my .bash_profile to make sure my PATH was correct. Updating my .bash_exports to make sure my PATH and NODE_PATH are correct. Updated my machine to macOS Sierra.
In iTerm:
node -v returns v11.3.0
which node returns /usr/local/bin/node
echo $PATH returns /usr/local/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/node
echo $NODE_PATH returns /usr/local/bin/node
Note: I don't want to uninstall Sublime as this is on my work machine and it's a pain in the butt to deal with IT with the sublime license.
After un-installing everything and re-installing everything, nothing worked. I gave up on n or nvm for the time being, and completely un-installed them. I even uninstalled Sublime and reinstalled it. The last thing I did was un-install and re-install sublimelinter eslint, which seemed to fix the issue. I'm not sure if that was really the fix, because I had already done that multiple times. The issue is resolved for the time being. I will update if the issue resurfaces.
tl;dr: how to install node properly, without all the $PATH errors and command not found?
Let me illustrate my problem with the following story:
I've been trying to install node "properly". I did the basic install, with it's installer, and found this (tl;dr: do not sudo node).
Ok, let's remove node and reinstall it with nvm and all. Great. Now, my $PATH doesn't point properly. Let's search a way to fix the $PATH.
Fixed the $PATH after several tries and failures? Great. Let's test... node -v returns 4.5.0... hmm, I'm sure it had a different version. Anyways, let's try installing gulp.
npm install --global gulp-cli, great, installed. Let's npm gulp -v to see if everything is alright —and it looks alright, as it returns 2.15.9.
So, if I just gulp it should return an error (as I don't have a gulpfile or packages.json). When I gulp at the terminal, it returns: zsh: command not found: gulp
So, i find out there's something not working properly again.
After several tries, removes, uninstalls and reinstalls, I beg your help. How can I remove everything node related from my computer and which is the best way to install node? I just want to use gulp, eslint and sublime text 2 with it.
If I'm doing something terribly wrong or saying incorrect things... call me dumb but please do correct me.
OSx El Capitan 10.11.16
iTerm2 3.0.7 with Oh My Zsh
Sublime Text Stable Channel, Build 3114
I did try with Homebrew and it worked properly.
I installed Node with NVM as I would not like to use sudo for access permission purposes.
I got the installation of nvm, installed node, installed npm and some npm packages.
The next morning I power on my mac and everything is not working anymore.
I guess ~/.nvm/v0.10.33/bin is not on my $PATH, but I'm confused as it was totally working fine yesterday.
P.S., The command nvm still works on my terminal though.
Nvm(nevermind). I got it working by setting the default to my node version by:
nvm alias default v0.10.33
So everytime I open a new terminal, node and other command just works.