How do I run a Node.js program?
Save your JavaScript in a file, like hello.js, then run node hello.js in your terminal. If Node.js is installed, it executes the file and prints any console output to the terminal.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in How to Write Your First Node.js Program
Install Node.js LTS, create a file called hello.js with console.log('Hello from Node.js'), run it with node hello.js, then try requiring built-in modules like os to access system information. That is your first Node.js program.
Start with console.log to confirm it works. Then try requiring a built-in module like os or fs to access system information or the file system. This shows you what server-side JavaScript can do that browser JavaScript cannot.
Use the built-in http module: create a server with http.createServer that responds with 'Hello World', and listen on a port. This is the foundation of backend development with Node.js.
Still have questions?
Browse all our FAQs or reach out to our support team
