How to Run a Node.js Application on a Mac

See JavaScript: Tips and Tricks for similar articles.
Looking to improve your JavaScript skills? Check out Webucator’s JavaScript classes.

Node.js makes it possible for you to run JavaScript programs outside of a web browser or on a server. To run a Node.js application on MacOS, follow these three steps.

  1. Open Terminal by pressing Command+Space to open Spotlight Search and entering terminal into the search box.Using Spotight to open Terminal
  2. Enter the following command, then press Return to create a file named test-node.js containing a simple application that will print out the result 1 + 1.
    echo "console.log(1+1);" >> test-node.js
  3. Type node followed by the name of the application, which is test-node.js in this case, and then press Return.
    node test-node.js
    The result of running the application will be printed out to the terminal.Result of Running the Application

Related Articles

  1. How to Install Node.js on a Mac
  2. How to Run a Node.js Application on Windows
  3. How to Send and Receive JSON Data to and from the Server
  4. How to Run a Node.js Application on a Mac (this article)
  5. How to Open Google Chrome's JavaScript Console
  6. How to Create a Google Map Object with the Maps JavaScript API
  7. Why JavaScript is called JavaScript
  8. How to Learn JavaScript on Your Own
  9. How to Install Node.js on Windows