If you are just starting with JavaScript development for building websites, APIs, or using tools like React, Angular, or anything, you will need Node.js and NPM on your system.
Although this is not a very complex thing to do, it will take up quite a good amount of time if you do not have the right guide.
So, here is one, and by its end you will be ready to run Node and NPM commands smoothly. We will cover both Windows and Mac systems.
What are Node.js and NPM?
To prepare for the installation, we must familise ourselves with the concepts. You are going to find a lot of formal definitions but let us understand these concepts in simple language.
Think of Node.js as a special engine (runtime environment) that lets your computer understand and run JavaScript code without a browser. And, understand NPM as a massive app store for JavaScript where you can find, download and organise all types of useful code bits for the projects.
How do I install Node.js and NPM on Windows?
Now let us guide you through the installation of Node.js and NPM on Windows, which has quite simple steps. And the best thing is that the Node Package manager (NPM) comes attached to Node JavaScript which means that you do not have to install it separately.
- Go to the official Node.js website, where you will see two download options: LTS and current.
- Click the Windows installer icon on LTS, and a .msi file under the LTS version.
- Once the file finishes downloading, open it and launch the installer.
- Click the next button on the welcome screen, accept the license agreement, click next button, choose the installation path or leave it by default, click the next button and make sure that “Node.js runtime” and “npm package manager” are selected.
- Click on Install button and wait for the installation to complete.
- Go to CMD and type node -v , you should see the version info of Node.js.
- Check NPM too by typing npm -v, which will help you confirm the NPM status.
Congratulations, this was it, and you have completed the steps on how to install Node.js on Windows with a successful installation.
Best way to install Node.js on Mac
Now let us look at the best way to install Node.js on Mac. Although there are a few ways to do it, we will show you the most beginner-friendly method by using the official installer.
- Go to the official Node.js website and choose the macOS installer (.pkg) under the LTS version.
- Download the file and open the downloaded file.
- Follow the installation wizard and click on “continue” and “install.”
- For final installation permission, you have to enter your Mac password.
- After installation completes verify it from the terminal app by typing node -v to see the installed version of Node JavaScript.
- For checking NPM, you can type npm -v.
Here is how you can install both of them on your mac system which is also the best way to install Node.js.
How to update Node.js and NPM?
Ok, if you have installed it, how are you going to update Node.js and NPM to get newer features on your Windows or Mac machine? Well, you know it already.
On Windows
- Visit the official website.
- Download the latest LTS installer.
- Run it like before and it will automatically update the current version.
On Mac
- Open the terminal app on your Mac.
- Type “npm install –lts nv, use –lts.”
- This will update both the packages on your Mac.
- In case you only want to update NPM, then type “npm install -g npm.”
Common errors to take care of
There are a few common errors that you might face when you install Node.js and NPM on your Windows or Mac machine.
- The first one being “command not found for node or npm?” To solve this, make sure the path was added correctly during the installation or you have to restart your terminal or system.
- The second problem can be “NPM permission errors on Mac.” To solve this, try using sudo before the commands or consider using nvm to completely avoid the permission issue.
What is Next?
If you successfully finish installing Node.js and NPM, you can now move to your goals with modern JavaScript development. These goals can be building a simple web server or launching your first full React or Vue project. However, know that if your requirements are too difficult and you are running short on time, it is a good idea to hire a JavaScript app development company and save time.