Facebook Pixel
How to Write Your First Node.js Program

What is different about running JavaScript in Node.js vs the browser?

The answer

In Node.js, you can access the file system, network, and system information through built-in modules. In the browser, JavaScript is sandboxed. Running node hello.js gives JavaScript full system access, which is the key difference.

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.

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.

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.

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.