The usual way to run a Node.js program is to run the globally available node command (once you install Node.js) and pass the name of the file you want to execute . While running the command, make sure you are in the same directory which contains the app.js file.
- Step 1: Save your javascript with . js extension.
- Step 2: Open the command prompt.
- Step 3: Locate your path where the . js file is saved.
- Step 4: To compile the .js file we have to write.
- Node .js.
- Step 5: Press the Enter key.
- Output: