Setting up npm and Node.js
Before setting up npm and Node.js, let us understand these terminologies and how they help us in application development. Node.js is a JavaScript runtime environment built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. npm from Node.js is the package manager for JavaScript which helps in discovering the packages of reusable code and assembles them in powerful new ways. By using npm, you can install, share, and distribute your code easily and manage the project dependencies wisely. Node.js installation comes with npm and can be downloaded and installed from its home page.
We used the latest stable version available (v6.11.1 LTS) for the setup, as shown in the following steps:
- Download Node.js, installable from its home page (https://nodejs.org/en/).
- Run the installable, which starts up with the following interface:
- Click Next and accept the terms in the following interface:
- Choose the installation directory. I am happy with the default directory provided and continue to the Next step, as follows:
- The next step gives us the Node.js runtime engine and npm package manager along with the documentation shortcuts and path entries. We can leave the default options selected and go to the Next step, which takes us to the final step:
- Click on the Install button, which should install Node.js, along with the npm package manager, on your computer:
Please be advised that neither the Node.js nor the npm have GUI. They are only accessible through the command line interface, hence you would need to run the commands on the command line.
- Once the installation is complete, you should see the success status as follows:
- Once the Node.js and npm installation is complete, you can open the command prompt and verify the installation and version using the commands shown in the following screenshot: