Where to place JS files for NodeJS to see them

You'll have to navigate to the correct folder "manually", in the Node Command Line Interface (CLI).

If you need to change drives, type the drive letter and a colon to switch to that drive, like so;

C:> (<- this is the line prompt, yeah? Just add this after it -> D:

That changes the drive. Now write cd (CD = "Change Directory") and the name of the direcotry you want to go to the directory your stuff is in:

D:> (<- the new prompt. Write something like this after it: ->) cd myprosject\subfoldername D:\myproject\subfoldername> (<- your new line prompt - if "myproject\subfoldername" exists)

now ask node to execute your script (that is stored in myproject\subfoldername, like so;

D:\myproject\subfoldername> node helloworld.js

Remember to write "node" first - otherwise the command won't go to node, but to the OS, which will probably just open up the js file in a text editior instead of running the goodies inside.


It is very easy.. Go to your command line. navigate to the file location.. then simply run the node helloworld.


You put them in whatever folder you want. It is common practice to put each application in a different folder.

Then you run node.js like this:

node /path/to/file.js

Or like this:

cd /path/to/
node file.js

Where file.js might look something like this:

console.log('hello world');