June 2022
Intermediate to advanced
410 pages
5h 8m
English
In this chapter, you’ll write, run, and debug your first Node.js programs. To keep it simple, these won’t use any third-party modules or npm. They’re self-contained scripts that use the standard library provided in Node.js.
Command-line console applications can be useful for automating tasks, formatting data, manipulating files, or any other laborious job that’s best handled by a computer.
Create a directory for your project, such as console:
mkdir console
cd console
Then add a file named hello.js with the following content:
#!/usr/bin/env node
// output message
console.log('Hello World!');
Save and run it from the command line:
node hello.js
You should now see Hello World! ...
Read now
Unlock full access