How to properly install node on OSx? - node.js

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.

Related

npm - The system cannot find the path specified (But then shows the result)

I am using npm after installing nodejs.
I have installed it once before and I just finished deleting all the components because it kept giving the error in the image below, but when I try to use npm, I keep getting errors saying.
The system cannot find the path specified.
Even though I reinstalled node, it still gives these weird errors where it says the error twice on powershell and once on cmd.
I'm so confused :(
In case you are using nvm to manage your node versions. You can just change your node version and it should work. This solution worked for me.
Check the current nvm version by using the command nvm current.
If that is not the version which you currently installed or updated, use the command nvm use <new_version>
for example: nvm use 16.17.0

Nvm and Node keep going missing upon closing terminal

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

Sublime text cannot find Node.js. How do I help Sublime find Node properly?

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.

Installing global npm package (#vue/cli) in Node v10.9 also installs Node v10.8?

This is weird, and I can't find a real answer for it - I suspect that its "supposed to do this" but it was strange. Here's what I did:
Completely cleaned node out of my system (OSX)
Reinstalled NVM and installed latest Node (10.9.0)
Verified that there were no other nodes being seen by NVM, verified all my paths, checked versions, etc. I was definitely in 10.9, and it was the only node installed.
I installed the vue client package: npm install -g #vue/cli
The package installs, no problems.
Typing vue and no binary is found.
If I run nvm ls I now have a v10.8.0, and when I explore that node's /bin folder, sure enough the vue binary was installed there, NOT in v10.9
I don't really have an issue with this, but I'd really like to know WHY this is happening, and what bad effects it might have later. I can easily move my default to 10.8, but I'd like to know why.
Is this something that the vue-cli package maintainers do? Is it because its a scoped npm package? Or something else entirely?
Figured this out. Leaving instructions for anyone else who might come along:
I ran npm config list and to my surprise found out that there was a .nvmrc file in my home folder that was overriding the "prefix" variable, pointing me to 10.8 instead of 10.9.
Deleted that file, and all is well. Sheesh.

npm get prefix: command not found

Trying to install firebase on the command line, can't do it because I probably need to change npm permissions. Problem is, when I run "npm get prefix" it comes back with "command not found". I know I have node.js, npm, git and bower installed, but I am very new to the command line and can't find anything online that references this. Can anyone help? Using Mac OSX.
I should specify what was going on here: I tried re-installing node.js a few times and it didn't work. I was re-installing the most recent version and for some reason my terminal didn't see it. The problem was fixed when I installed the LTS (Long Term Support) version.

Resources