Running JavaScript Files in Node.js

The other option for running Node.js code is to simply write JavaScript code into a file, and then compile basic arithmetic operators using node.js server.

Create a new project using "File" -> "New" -> "Project..." then select Empty Location. Name it “Nodeproject".

Nodeproject

Now, New -> The app folder has scripts.

Add new JavaScript file Name -> Server.js -> OK.

Add

Run a script file in Node.js from WebStorm.

script file

Run Node.js from the command line and execute the file as in the following figure,

command line

Arithmetic operators

There are the four basic arithmetic operators, as well as the modulus operator (%) which is used to obtain the division remainder.

The output Node Server is running as shown,

output

Run Node.js from the command line and execute the file as in the following figure,

output

GitHub

Ebook Download
View all
Learn
View all