Latest Guide to Install npm and node js in Mac OS

Just like other JavaScript frameworks React Native also requires npm to manage the dependency so here is the Latest Guide to Install npm and node js in Mac OS.

For those who are new in the Javascript framework world

npm is a package manager for the JavaScript programming language. It is the default package manager for the JavaScript runtime environment Node.js. It consists of a command line client, also called npm, and an online database of public and paid-for private packages, called the npm registry.

We can say that npm is a package manager for Node.js with hundreds of thousands of packages.

Although it does create some of your directory structure/organization, this is not the main purpose. The main goal, as you touched upon, is the automated dependency and package management.

Whenever you work with npm/node you can see it manages a file called package.json in which it stores all the dependency you have used in your project under the dependency section. Which means you can specify your project’s dependencies in the package.json file and any time you or anyone else needs to get started with your project they can just need to run npm install which will install all the dependencies in the node_module directory. On top of this, it is also possible to specify what versions your project depends upon to prevent updates from breaking your project.

In this example, we will show you how to install npm and node js in Mac OS, If you have a Linux or Windows machine then please visit Latest Guide to Install npm and node js for Ubuntu and Windows.

Prerequisites

Before you can install Node, you’ll need to install two other applications. Fortunately, once you’ve got these on your machine, installing Node takes just a few minutes.

  1. XCode. Apple’s XCode development software is used to build Mac and iOS apps, but it also includes the tools you need to compile software for use on your Mac. XCode is free and you can find it in the Apple App Store.
  2. Homebrew. Homebrew is a package manager for the Mac — it makes installing most open source sofware (like Node) as simple as writing brew install node. You can learn more about Homebrew at the Homebrew website. To install Homebrew just open Terminal and type ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)". You’ll see messages in the Terminal explaining what you need to do to complete the installation process.

Install npm and node js in Mac OS

1. First of all, you need to check whether Homebrew is installed in your Mac or not? To check this run

If you already have Homebrew installed it will show you the installed version of Homebrew

else will show brew: command not found

2. If you have Homebrew installed then you can skip this step else install Homebrew using

3. Now after installing brew you can run the following command to install node and npm in your Mac. This will completely install node into your Mac.

4. After installation of node. You can check using

This will show the installed version of node and npm in your Mac.

How to Update Node and NPM

New versions of node and npm come out frequently. You can use Homebrew to update the software it installs.
1. Make sure Homebrew has the latest version of the Node package

2. Upgrade Node

How to Uninstall Node and NPM

You can use Homebrew to uninstall packages

This was the best way to install the nodejs and npm in Mac OS. If you are facing any problem or if you have any doubt about the topic you can comment below or contact us here.

Hope you liked it 🙂

How useful was this post?

Click on a star to rate us!

Average rating / 5. Vote count:

As you found this post useful...

Follow us on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

About Snehal Agrawal

#SelfLearner #MobileAppDeveloper #TechnologyMiner #OpenSourceLover thats enough to describe me..

View all posts by Snehal Agrawal →

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.