Let's recall how to run a file with node. You can either cd down to the folder where the file resides or just explicitly state the file path (note, this is bash that I'm using in the mac terminal program):
Now here's the magic. If you just specify the name of a directory with no file name then node will automatically look for a file named index.js inside the specified folder:
The cool thing is that all of these commands will run the exact same file in the exact same way. Here's a super simple one-liner sample index.js file for you to try it out yourself!
The posts on this site are written and maintained by Jim Lynch. About Jim...
Want FREE access to
my daily stock tips
"The Triple Gainers"?
Sign up here!