What is different about running JavaScript in Node.js vs the browser?
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.
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.
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
