Let’s examine a simple example. I provide a screen capture of the code and the result. Let’s examine the code below.
You note that I used the command node and specified the location of the file (example2.js in the same directory). Identical code running on a Mac yields similar results in terminal (below).
Assuming you are trying this out and downloaded the zip files (see end of this post for the link), you should have similar results. You have now verified that you have Node.js installed and working properly.
Next, we try out some bad code (I know this is a simple example, but I wanted to focus on the techniques). I ran jshint first and saw errors. I then ran node just to show what happens when you try to run poorly written code.
Note that this post was inspired by a course I recently completed at lynda.com – Node.js first look by Joseph LeBlanc. I also recently completed the book JumpStart Node.js by Don Nguyen. I am curious about your experiences with Node.js. Please post your comments in the space provided. I do need to approve them due the volume of spam comments I receive.