NodeJS Series Part 3: Using External Files

This time we will create external JavaScript files to be called from the NodeJS command prompt.

Create a new JavaScript file (for instance I've created sample.js).

Add the following JavaScript lines as an example:

  1. console.log("Poooff");  

When we call an external file from the nodejs command prompt, it shall write “Pooff” as output.

Store this file in a close destination that is easy to access later from the command prompt. Now open the “Nodejs Command Prompt” application and call this:

node5

Then press Enter and see what happens. For me, I get:

node6

It's that easy to call external files with Nodejs.

Do you want a much more complicated and useful solution? The next article will be about that.