Today, we cannot deny the popularity of Node.js, which exists in all fields: Micro-services, IoT (automation), Cross Platform (electron.js), etc. Besides, it is a helpful tool in modern front-end websites (Server Side Rendering, build tool – web pack, etc.). So, today’s article will briefly introduce Node.js and how to install and use this language.
What is Node.js?
Introduce
Node.js is a cross-platform javascript runtime. The development team used Chrome’s V8 JavaScript engine to build it with the performance mindset. And it will compile JavaScript directly to native machine code.
When talking about that, we should talk about the following:
- Event-based
- Non-blocking
- Asynchronous I/O runtime
How to install Node.js?
To manage multiple versions of Node.js, we will install nvm
Windows
- Uninstall any existing versions of Node.js.
- Delete any existing Node.js installation directories (such as C:\Program Files\nodejs)
- Delete the existing npm install location (such as C:\Users\<user>\AppData\Roaming\npm)
- After this, download and run the latest stable installer, and you should be ready!
MacOS/Linux
with cURL command
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash
with Wget command
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash
This will clone the nvm repository to ~/.nvm and make the required changes to your bash profile so that nvm is available anywhere in your terminal.
Using nvm
Install node version
nvm install 12.16
List all nodes installed.
nvm list
Use specific node version
nvm use 12.16.2
Check it
node -v
npm -v
Quick view for Node.js
Node.js allow running JavaScript on the Server, but that’s not new. Coming back to 1994, Netscape is the first attempt to do that. However, Node.js is the first implementation to gain any real traction. That provides some unique benefits compared to traditional languages.
Execute Model
Node.js is single-threaded, but in the background, it uses multiple threads to execute asynchronous code with the help of the libuv library.
It’s also event-driven, which means that everything that happens in Node is in reaction to an event.
- A new request comes in (one kind of event), and the server will start processing it.
- If it encounters a blocking I/O operation, it will register a callback before processing the next event.
- When the I/O operation has finished (another kind of event), the server will execute the callback and continue working on the original request.

What kind of Apps is Node.js suited to?
Generally, it can use in any business domain. But to be relevant to the strength of it, we need to focus on some aspects.
- Real-time interaction or Collaboration (chat, codeshare)
- API handles lots of requests that are
- I/O driven (such as those needing to perform operations on a database)
- Sites involving data streaming (Node makes it possible to process files while they’re still being uploaded)
- Simple CRUD app. (There are a lot of frameworks that support us in building CRUD app)
Besides that, we can use it in other use cases:
- Used as a scripting language:
- To automate repetitive tasks on your PC
- For error-prone tasks
- Write your own command line tool.
- Build cross-platform desktop apps.
- Create your own robots.