Node.js is a JavaScript platform for general-purpose programming that allows users to build network applications quickly. By leveraging JavaScript on both the front and backend, Node.js makes development more consistent and integrated.
- Introduction
- Node.js Installation on Windows
- Node.js Installation on Ubuntu
- Making a Simple Node.js Server
- Conclusion
Introduction:-
Node.js is a very strong JavaScript-based server-side stage used to foster I/O escalated web applications like video web based locales, single-page applications, online talk applications, and other web applications.
Node.js is utilized by huge, set up organizations (Netflix, Paypal, NASA, and Walmart, to give some examples) and recently stamped new companies the same. The stage offers a lot of benefits of real value, settling on it a preferable decision over other server-side stages like Java or PHP as a rule.
The accompanying article covers the total Node.js establishment on Windows and Ubuntu. We’ll likewise make an essential Node.js server, eventually, to confirm assuming everything is working appropriately.
Node.js Installation on Windows
In this segment, we’ll be taking a gander at Node.js establishment on Windows. Assuming you’re a Ubuntu client, you can get out ahead to the following segment that arrangements with Node.js establishment on Ubuntu.
Steps to Install on Windows:
1. Download Node.js from https://nodejs.org/en/download/.
2. Select the Windows installer as per your framework climate (32-bit or 64-cycle).
3. Run the downloaded Node.js installer.
4. Acknowledge the permit understanding. You can leave different settings as default. The installer will introduce Node.js and brief you to tap on the completion button.
5. Check that Node.js was appropriately introduced by opening the order brief and composing this order:
6. At the point when we introduce Node.js, NPM (Node Package Manager) likewise gets introduced. NPM is remembered for the establishment as it incorporates numerous libraries that are utilized in web applications like React. So we should confirm assuming it’s introduced involving this order in cmd:
That is all we really want to accomplish for a fruitful Node.js establishment on a Windows framework! Assuming you’re a Windows client, you can avoid the following area and hop directly to the part wherein we’ll make an essential Node.js server to confirm if everything functions true to form.
Node.js Installation on Ubuntu :-
Here, we’ll complete Node.js establishment on the Ubuntu framework.
Steps to Install on Ubuntu:
1. To begin with, add the Node.js PPA to our framework to introduce Node.js on Ubuntu:
sudo able get introduce twist
twist – sL https://deb.nodesource.com/setup_12.x | sudo – E slam –
2. Presently run the underneath order to introduce Node utilizing adept get. This will likewise introduce NPM with Node.js:
sudo able get introduce nodejs
3. Confirm that Node.js and NPM are appropriately introduced, by running this order:
Since we’ve finished the establishment of Node.js on the two Windows and Ubuntu Operating Systems, we should make a basic Node.js web server.
- var http = require(‘http’);
- http.createServer(function (req, res) {
- res.writeHead(200, {‘Content-Type’: ‘text/plain’});
- res.end(‘Hey! You have effectively made a web server!!’);
- }).listen(3000, “127.0.0.1”);
- console.log(‘Server running at http://127.0.0.1:3000/’);
- We pronounce a variable http that imports and contains the http module, which is needed to collaborate with the web
- HTTP module has a strategy called createServer that makes a server utilizing a capacity with boundaries req (solicitation) and res (reaction)
- We utilize the res (reaction) boundary to send a string to the page
- From that point forward, we set the server to tune in at port: 3000 and URL: “127.0.0.1”
- We utilize the console.log technique to log the result of the program in the cmd or terminal. Assuming that the program turns out great, this technique shows the string encased in the sections
- At last, we save the record as server.js
Making a Simple Node.js Server:-
In this segment, we’ll make a basic Node.js web server. For this, we’ll require a word processor, ideally VS Code or Atom. The code to make the server is as underneath:
Code clarification:
We would now be able to begin the Node.js server that we recently made utilizing the order:
Since we get the String that we characterized inside the sections of console.log strategy, we can see that Node.js server is currently running and functioning true to form.
We can likewise check the reaction on the page by going to the characterized URL and port.
Since this additionally turns out totally great, we can presume that we’ve effectively introduced Node.js in our framework.
Presently the following coherent advance is begin getting more familiar with Node.js and ultimately gain a few active information about this extremely well known server-side stage.
Conclusion:-
Now that you’ve learned about Node.js installation on Windows and Ubuntu, you may be wondering how you can obtain the skills necessary to take advantage of its rising popularity.
Fortunately, there are some great options for learning this exciting and practical skill set at your own pace. ACTE’s Node.js Certification Training will give you a great foundation in this popular platform, combining live, instructor-led training, self-paced tutorials, and hands-on projects to help you become career-ready upon completion. Get started today to seize your future!