When doing front-end development, you always come across NPM command. One of the most popular command would be npm install
. So today we will learn about how to install Node.js and NPM. Let us start with little introduction on Node.js and NPM.
What Will We Learn
- What Node.js and NPM are
- Install Node.js and NPM
- Way to verify installation
What is Node.js?
Node.js is a server-side programming language in JavaScript. The purpose of Node.js is to unify the programming language for web development on client side and server side under one language which is JavaScript.
What is NPM?
NPM is a standard package manager for Node.js. It starts as a tool for Node.js to download and manage dependencies. After years of development, NPM has become the largest repository for front-end JavaScript.
Install Node.js and NPM
Go to Node.js official download page, download the LTS version. LTS stands for long term support. It is a version which is built for production. Therefore, it has longer support period compared to other releases.
I take Windows Installer as the example. If your computer can support 64-bit, then go for 64-bit Windows Installer for best performance.
Firstly launch the installer, click Next to proceed to next step.
Then tick and agree to the license agreement.
Next select the directory to install Node.js and NPM.
You can choose what to install here. However you can leave it as default if you not sure about what they are.
You can leave this option uncheck, it is not required in most of the front-end development. Tick on this option to install the module only if you are required to compile C/C++.
Finally, click on Install, the installation will start. On the other hand, you may still go back now and review your choice before installation.
When you reach until here, you have successfully installed Node.js and NPM.
Verify Installation
Now you can test and verify the installation with node -v
and npm -v
. As a result, it should show installed Node.js and NPM version. Cheer! At last, you make it.
Possible Error and Solution
If you face the error below when enter npm -v
.
npm WARN npm npm does not support Node.js v14.17.0 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 6, 8, 9, 10, 11, 12. npm WARN npm You can find the latest version at https://nodejs.org/
In that case, go to C:\Users\YourAccountName\AppData\Roaming
and delete npm and npm-cache. After that, open your command prompt or terminal and enter this.
npm install -g npm@latest
This should fix your problem. Let me know if you have any issues, or what would you like to know more about Node.js and NPM.