How to Run a Node.js Application on a Mac
See JavaScript: Tips and Tricks for similar articles.
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.
- Open Terminal by pressing Command+Space to open Spotlight Search and entering
terminalinto the search box.
- 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 - Type
nodefollowed by the name of the application, which is test-node.js in this case, and then press Return.
The result of running the application will be printed out to the terminal.node test-node.js
