How To Install Node Js Npm
To showtime building your Node.js applications, the first step is the installation of the node.js framework. The Node.js framework is available for a variety of operating systems right from Windows to Ubuntu and OS Ten. In one case the Node.js framework is installed, you lot can start building your kickoff Node.js applications.
Node.js as well has the power to embedded external functionality or extended functionality by making use of custom modules. These modules have to be installed separately. An example of a module is the MongoDB module which allows you to work with MongoDB databases from your Node.js application.
In this tutorial, you will acquire-
- How to Download & Install Node.js on Windows
- How to Install NPM on Windows ten/8/7
- Running your starting time "Hello World" application in Node.js
How to Install Node.js on Windows
The offset footstep in using Node.js is the installation of the Node.js libraries on the client organization. Below are the steps to download and install Node.js in Windows:
Step 1) Download Node.js Installer for Windows
Go to the site https://nodejs.org/en/download/ and download the necessary binary files.
In our example, nosotros are going to Download Node.js on Windows with the 32-bit setup files.
Step 2) Run the installation
Double click on the downloaded .msi file to commencement the installation.
Click the Run button on the first screen to begin the installation.
Step 3) Continue with the installation steps
In the next screen, click the "Next" push to go along with the installation
Step 4) Have the terms and conditions
In the adjacent screen, Accept the license agreement and click on the Adjacent button.
Step 5) Set up upward the path
In the next screen, cull the location where Node.js needs to be installed and and then click on the Next push button.
one. Beginning, enter the file location for the installation of Node.js. This is where the files for Node.js will be stored later on the installation.
2. Click on the Next button to proceed ahead with the installation.
Pace half-dozen) Select the default components to be installed
Accept the default components and click on the Next button.
Step 7) Start the installation
In the next screen, click the Install push to start installing Node.js on Windows.
Step 8) Consummate the installation
Click the Terminate button to consummate the installation.
Windows is now recommending that developers use Node.js with WSL2(the Windows subsystem for Linux)
How to Install NPM on Windows x/8/seven
The other way to install Node.js on any client motorcar is to use a "packet manager."
On Windows, the NPM (Node Package Managing director) download is known as Chocolatey. It was designed to be a decentralized framework for quickly installing applications and tools that y'all demand.
For installing NPM on Windows via Chocolatey, the following steps need to be performed.
Step i) Installing Chocolatey – The Chocolatey website (https://chocolatey.org/) has very articulate instructions on how this framework needs to exist installed.
- The get-go step is to run the below control in the command prompt windows. This command is taken from the Chocolatey web site and is the standard command for installing Node.js via Chocolatey.
- The below command is a PowerShell control which calls the remote PowerShell script on the Chocolatey website. This command needs to be run in a PowerShell command window.
- This PowerShell script does all the necessary piece of work of downloading the required components and installing them accordingly.
@powershell -NoProfile -ExecutionPolicy Bypass -Control "iex ((new-object moisture.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && Fix PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
Step two) The next stride is to install Node.js to your local car using the Chocolatey, package managing director. This can be washed by running the below command in the command prompt.
cinst nodejs install
If the installation is successful, you lot will get the message of the successful installation of Node.js.
Annotation: If yous get an fault like "C:\ProgramData\chocolatey\lib\libreoffice\tools\chocolateyInstall.ps1" So manually create the folder in the path
Running your first Hello Globe application in Node.js
One time you lot accept Node.js download and installed on your computer, let'south effort to brandish "How-do-you-do Globe" in a spider web browser.
Create file Node.js with file proper name firstprogram.js
var http = crave('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/html'}); res.end('Hello Earth!'); }).heed(8080); Code Explanation:
- The basic functionality of the "require" office is that it reads a JavaScript file, executes the file, and and so gain to return an object. Using this object, one can then employ the various functionalities bachelor in the module called by the require office. So in our case, since nosotros want to apply the functionality of HTTP and we are using the crave(http) command.
- In this 2nd line of code, we are creating a server application which is based on a simple function. This function is chosen, whenever a request is fabricated to our server awarding.
- When a request is received, we are asking our part to return a "Hello Globe" response to the client. The writeHead office is used to send header data to the customer, and while the terminate function will shut the connection to the client.
- Nosotros are then using the server.listen role to make our server application mind to customer requests on port no 8080. Y'all can specify whatsoever bachelor port over hither.
Executing the code
- Salvage the file on your calculator: C:\Users\Your Proper noun\ firstprogram.js
- In the command prompt, navigate to the folder where the file is stored. Enter the command Node firstprogram.js
- At present, your calculator works as a server! If anyone tries to access your computer on port 8080, they will get a "Hello World!" message in return!
- Beginning your internet browser, and type in the address: http://localhost:8080
OutPut
Summary
- Nosotros have seen the installation of Node.js via the MSI installation module, which is available on the Node.js website. This installation installs the necessary modules which are required to run a Node.js awarding on the client.
- Node.js tin also be installed via a bundle manager. The package managing director for windows is known equally Chocolatey. Past running some unproblematic commands in the command prompt, the Chocolatey parcel managing director automatically downloads the necessary files and then installs them on the customer motorcar.
- A uncomplicated Node.js awarding consists of creating a server which listens on a particular port. When a request comes to the server, the server automatically sends a 'Hello Globe' response to the customer.
Source: https://www.guru99.com/download-install-node-js.html
Posted by: austinousioner.blogspot.com

0 Response to "How To Install Node Js Npm"
Post a Comment