Run Node js Application

After successful node.js installation, let's learn to execute node.js commands and programs.

These are the ways to run the Node.js application


By using command prompt

For this, go to start, type cmd and launch command prompt. On command prompt type the following command, we can also open the node shell in cmd by simply typing node command.


nodejs version

By using node shell

For this, go to start and search for 'Node.js', you will get a symbol of node.js, click on it to launch the node shell.

run nodejs on shell

Run Node.js script file

To execute node.js script file, simply run $ node filename. Suppose we want to execute 'test.js' file, then simply run the following command.

$ node test.js

Run inline Node.js script

We can also run a quick set of statements in node.js. It provides -e option to run the inline statement.

$ node -e "console.log(new Date());"