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.
How to Write Your First Node.js Program
What should my first Node.js program do?
The answer
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.
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.
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
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.