How to Install node.js and NPM on Windows? Node.js is a run-time environment that comes with everything you need to run a JavaScript program. Before content is sent to a web browser, it is used to run programs on the server to render it.
Node Package Manager, or NPM, is a tool and repository for creating and exchanging JavaScript code.
This post will assist you in setting up Node.js, NPM, and other helpful Node.js commands on a Windows computer.
A user profile with administrative rights (or the ability to download and install software)
Either Windows PowerShell (Search > PowerShell > right-click > run as administrator) OR the ability to use the Windows command line (Search > cmd > right-click > run as administrator)
Go to https://nodejs.org/en/download/ via a web browser. To get the most recent default version, use the Windows Installer option. Version 10.16.0-x64 was the most current version at the time this article was written. The NPM package manager is included in the Node.js installer.
Launch PowerShell or a command prompt and type the following:
node -v
The Node.js version that is currently installed on your machine ought to be visible. The same applies to NPM:
npm –v
Node.js can be removed from Windows’ Control Panel.
To do this:
Select "Start" > "Settings" (the gear icon), then "Apps."
Click to highlight Node.js after scrolling down to find it.
Choose Uninstall. This starts the program uninstall wizard.
Node.js is a framework, thus it doesn’t function like a typical application. Instead, it translates the instructions you type. Make a Hello World script to test your new Node.js installation.
1: Start by opening your preferred text editor:
2: After that, paste the subsequent content into the text editor you just launched:
var http = require('http');
http. create Server (function (req, res)
{
res. write Head (200, {'Content-Type': 'text/html'}
);
res. end ('Hello World!'
);
}). listen (8080)
;
3: After saving the file, go away. Launch PowerShell and type the following commands:
Users your username> node
js
It will appear that nothing has changed. Your script is actually executing in the background. If Windows Defender displays a warning about permitting traffic, click Allow for the time being.
4: After that, launch a browser and type the following into the address bar:
http://localhost:8080
You should see the words “Hello World” in the upper-left corner.
Your computer is currently working as a server. The Hello World message will appear on any other computer that tries to access your system via port 8080.
Switch back to PowerShell and hit Ctrl+C to end the program. The command prompt will appear once more on the computer. This window may be closed anytime you are prepared.
How to Install node.js and NPM on Windows? Both the Node.js framework and the NPM package management should now be installable. Additionally, you’ve created your first JavaScript node.js program!