skip to Main Content

Ok. For a very long time now I have been trying to figure out just one thing but can’t seem to grasp it. Please, someone. What is node JS used for? This google snippet…..

Node. js is primarily used for non-blocking, event-driven servers, due to its single-threaded nature. It’s used for traditional web sites and back-end API services, but was designed with real-time, push-based architectures in mind.

is a tad confusing. Anyone willing to break that statement down for me? I read things like how node js allows the ability to execute javascript code but doesn’t the normal web browser do that already? Or how it allows you to host static files but doesn’t my cPanel already do that?

Just simply, what in the world is node js used/best used for??

And yes, I’m aware that this had been asked more times than one could think. I just need an answer from someone in this time frame, not from an answer posted 8 years ago.

2

Answers


  1. I suggest you look at their official website for a clear answer: https://nodejs.org/.

    If you are still confused, basically Node.js is a JavaScript environment. It allows you to install packages, and run applications SERVER-SIDE.

    Every Node.js project has a package.json file which specifies all packages and scripts used in the project.

    To create a package.json file and a Node.js project, download node.js with the link I provided above, create a directory and navigate to it, and run:

    npm init.

    You can just keep pressing enter and use the default options. With a package.json file created you can now create a server-side web application with Express.js or some other framework that can run in the browser using the node {whatever your javascript file name is}.js command.

    Hope this helps!

    Login or Signup to reply.
  2. non-blocking, event-driven servers, due to its single-threaded nature

    So Node.JS runs things like network and file system requests concurrently with code execution so they’re "non-blocking" ie don’t halt code execution. It manages this by executing these requests in a separate worker-pool of threads then triggering events/callback functions. This means that it simplifies development as it allows one to develop without the complexities of manually managing multiple threads whilst still maintaining great performance characteristics.

    Node.JS is used primarily as a server-side technology however it can also be used to develop CLI applications. Yes the browser can execute JavaScript however it cannot run it on the server. Yes cPanel lets you host static files however NodeJS can allow you to run more complex tasks on said files, load data from databases, manipulate said data etc.

    What’s is best used for?

    Rapid development for web based application back ends and CLI applications which have good performance characteristics.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search