What is node.js?
Over the years, the modern web application has really come a long way with the implementation of many common frameworks like bootstrap, Angular JavaScript, etc. All these frameworks are based on popular application JavaScript. Yet there was a kind of void when it came to creating server-based applications, and this is where Node.js comes into the scenario. Node.js is also based on the JavaScript framework.
Node.js is an open-source server-side runtime environment based on the JavaScript V8 engine from Chrome. This offers an event-driven asynchronous I / O and cross-platform runtime environment for the use of JavaScript to create highly scalable server-side applications.
How to install node.js to your machine?
Installation of node.js framework is the first step to start building the Node.js applications. The node.js framework is designed for a range of operating systems, from Windows to Ubuntu to OS X. You can start building your first node.js applications once the node.js framework is installed.
Go to the [Link] https:/nodejs.org/en/download/ website and download the required binary files.
What is NPM (Node Package Manager)?
Node.js is installed to npm. The name NPM(Node Package Manager) derives from the time NPM was first created as Node.js package manager. All the NPM packages are defined in package.json files. The contents of package.json must be written in JSON.
You can check the installed NPM version by using npm -v command in command prompt.
Run your first application ‘Hello World’ in Node.js
After downloading and installing Node.js on your computer, let’s try displaying “Hello World” in a web browser. Let’s create a Node.js file with file name firstprogram.js in notepad.
You can save your code in your preferred location and I’ll save it in: ‘D:\nodeJS’
Navigate to the folder where the file is stored in the command prompt. Type ‘node firstprogram.js’ command in command prompt.
Now your computer is functioning as a server! If anyone on port 8080 tries to access your device, they will get the message “Hello World!” in return! Launch your browser, and enter the following address: http:/localhost:8080
Node.js can be installed through a package manager, too. The windows package manager is called Chocolatey. The Chocolatey package manager automatically downloads the appropriate files and then installs them on the client computer by executing a few simple commands in the command prompt.
A basic program called Node.js consists of building a server that listens to a specific port. The server will immediately send a ‘Hello World’ message to the client when a request hits the server.
Top comments (0)