Setting up the Environment with Node.js

Hello! I hope you had a good day and an awesome week. 😊

As I promised on the previous post, in this one we’ll do some coding using Node.js. But before we jump into coding, we need to set up a proper environment.

Setting up the Environment

Before working with Node.js, it should be installed to your machine. So, to install, you can follow the link given below,


There, select the setup according to the operating system of your machine. When installing go with the default options. After the installation, open command prompt and type ‘node --version’ as below,



If the version is shown, Node.js is successfully installed to your machine. If not, it should be reinstalled.

Let’s Code

Let’s start small. First, we’ll see how to print something in the command prompt. A JavaScript file (a file with .js extension) should be created. Let’s call it ‘Hello.js’. This can be done using a simple text editor or using and IDE (Integrated Development Environment) which supports JavaScript.  Inside the file write the following.


Here I have used ‘use strict’, which is using the strict notation. Strict notation is the restricted mode in JavaScript. It helps to write secure JavaScript. It makes bad practices in JavaScript into errors and will keep the developer away from using syntax which will get invalid with upcoming JavaScript versions.

To run this, the command prompt should be opened in the working directory (the directory which you are currently at or where the previously created file is stored). In the command prompt type ‘node <name of the file>’, in this case, the name of the file is ‘Hello.js’, in order to run the file.



Node.js supports basically everything JavaScript supports.

So now you got a basic idea how to code, I suggest you just play around with Node.js. In the next post, we’ll go into more deeper stuff.

I wish you all an amazing week ahead! Adios ðŸ˜Š

Comments

Popular posts from this blog

Double Submit Cookies Pattern - Node.js

Synchronizer Token Pattern - Node.js