- Restart terminal and install the latest version of Node. Nvm install node. Run the final command to confirm node is installed. Nvm use node node -v && npm -v #confirm the install worked.
- MacOS Package (.pkg) Installer. The easiest way to install MacPorts on a Mac is by downloading the pkg or dmg for Big Sur, Catalina, Mojave, High Sierra, Sierra, El Capitan, Yosemite, Mavericks, Mountain Lion, Lion, Snow Leopard, Leopard or Tiger and running the system's Installer by double-clicking on the pkg contained therein, following the on-screen instructions until completion.
- How to install Node on Mac using NVM and Homebrew Published: February 07, 2018 - 2 min read Node Version Manager makes it easy to install multiple Node versions on a Mac.
Installing and working with Node, npm, nvm on MacOS
How to Install macOS Catalina from Bootable Installer. Insert the Bootable Installer to your MAC. Restart your Mac. Power to the Mac and hold on to the Options button on the keyboard. Select the macOS Catalina alternative from the drop-down menu. Then, the utility window will be opened, you have to pick the disk drive utility. Once the download is complete, you will have the complete setup file for macOS Catalina available on your Mac. MacOS Catalina 10.15 is the latest update to Apple’s popular desktop operating system.
You can install node (which installs npm
and npx
along with it) either by
- Directly obtaining an installer from: https://nodejs.org/en/download/
- With the
brew
package manager (see below).
One of the easiest ways to do this on MacOS is via the brew package manager.
Installing brew
- To install
brew
, visit https://brew.sh and follow the instructions - Before installing anything with
brew
, it’s good practice to runbrew update
first. - If your
brew
install is messed up,brew doctor
can help restore a proper install.
Using brew
to install node
This command will install node
using brew
To test if it worked, you can try:
If you get an error like this one when you try to do npm install
, then you may need to reinstall your XCode tools.
Here are the instructions for doing so:
- https://medium.com/flawless-app-stories/gyp-no-xcode-or-clt-version-detected-macos-catalina-anansewaa-38b536389e8d
- NOTE however that there is a missing step in those instructions. After removing the old version of the XCode command line tools, to start theprocess of reinstalling the XCode command line tools, type
git
at the command prompt.
- NOTE however that there is a missing step in those instructions. After removing the old version of the XCode command line tools, to start theprocess of reinstalling the XCode command line tools, type
If that doesn’t work, here’s another option:
This worked for me.
Install full Xcode Open Xcode and the CLT will install Then run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
This uses the full Xcode CLT and node-gyp works.
These instructions work for Linux too.
Most node tutorials suggest installing node and then using the tool npm
.
It’s probably a better idea to work with nvm
if you are using your own computer, as that will allow you to maintain separate node environments fordifferent projects.
This StackOverflow answer explains more: http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo
See: https://github.com/creationix/nvm#install-script
See this StackOverflow answer: http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo
Related topics:
- Node: Linux—Installing and working with Node, npm, nvm on Linux
- Node: MacOS—Installing and working with Node, npm, nvm on MacOS
- Node: Windows—Installing and working with Node, npm, nvm on Windows
Different projects use different Node versions. That means you might have to switch your Node versions depending on the project. As you might imagine, installing and uninstalling Node version is time-consuming.
Thankfully, we have the Node Version Manager that allows us to switch between different Node versions easily. Thus, in this article, you will learn how to install it and use it on macOS.
The article illustrates two ways of installing the Node Version Manager. With Homebrew and with the cURL command.
Using the cURL command
One of the simplest ways to install NVM is to run the following cURL command in your terminal:
What does the command actually do?
- It downloads the nvm script from GitHub, and then it runs it.
- After that, it also clones the nvm repository to /Users/yourMacUsername/.nvm.
- Lastly, it adds a script to your profile file (~/.bash_profile, or ~/.zshrc, or ~/.profile, or ~/.bashrc) to enable you to use the nvm command in your terminal.
All you have to do now is restart your terminal, and you can use the Node Version Manager. Alternatively, if you do not want to restart your terminal after running the cURL command, run source ~/.nvm/nvm.sh in your terminal. Afterward, you can run the nvm commands straightaway.
Using Homebrew
Another method is to install the Node Version Manager with Homebrew. Run the below command in your terminal:
After the installation finishes, open your profile file (~/.bash_profile, or ~/.zshrc, or ~/.profile, or ~/.bashrc), and add the following lines to it at the end:
By adding the above lines to your profile page, you can run the nvm command in your terminal. If you don't add the above lines, you will get an error when you run nvm commands in the terminal. Going further, you need to restart your terminal to use the nvm commands in the terminal.
NVM commands
Now that you have NVM installed, let's see some of the most useful commands.
nvm ls-remote
First of all, we can run nvm ls-remote to find all the Node versions available for download. Caution: by running this command, you'll get a lot of versions.
Thus, it might take a while until it finishes.
nvm install
After running the command nvm ls-remote, we can install the version we want by running the following command:
For instance, if you want to install Node version 14, you need to run nvm install 14. It installs the latest Node 14 version. However, if you're going to install a particular version, you can specify it as follows - 13.10.1.
Tip: You can install the latest LTS version of Node by running nvm install --lts.
nvm ls
nvm ls lists all the Node versions installed on your machine. Don't confuse nvm ls with nvm ls-remote. The former one lists the ones installed on your machine, whereas the 'ls-remote' lists all the Node versions available for download.
Install Nvm Mac Catalina Os
nvm use
After installing the Node version you want, you can use it by running the following command:
By running this command, nvm switches the Node version to the one you specified.
Tip: To use the latest LTS version of Node by running nvm use --lts.
Conclusion
The Node Version Manager is a handy tool to switch between Node versions. To recap, in this article, you learned how to:
- install nvm using two different methods
- use nvm to install and use various Node versions
Install Nvm Catalina
For more commands, information, troubleshooting, and anything else, check the official nvm repository on GitHub.