What is Node.js

Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.

As an asynchronous event driven JavaScript runtime, Node is designed to build scalable network applications. This is in contrast to today’s more common concurrency model where OS threads are employed. Thread-based networking is relatively inefficient and very difficult to use. Furthermore, users of Node are free from worries of dead-locking the process, since there are no locks. Almost no function in Node directly performs I/O, so the process never blocks. Because nothing blocks, scalable systems are very reasonable to develop in Node.

Node.js’ package ecosystem, npm, is the largest ecosystem of open source libraries in the world.

With that said, let’s create our first node app, a simple Hello World.

First you need to check if you have node installed in your system, to do that, open a console and type: node -v. The output should be the version of node installed in your system.

v8.10.0

If a different message appears, you probably don’t have node installed, so follow the steps to install it. On Linux, open a console and run these commands.

$ cd ~
$ curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
$ sudo bash nodesource_setup.sh
$ sudo apt-get install nodejs build-essential

If you are a Windows or Mac user, refer to node website for more details on how to install it on your platform.

Leave a comment

Leave a Reply