๐ ๏ธ Prerequisites
Make sure the 1-node-farm starter folder is open. If you're currently in the project root, please open that folder instead.
๐ Step 1: Create a New JavaScript File
In the root folder of your project, create a new file named:
index.jsโ๏ธ Step 2: Write Your First Node Code
Inside index.js, write:
const hello="Hello world!";
console.log(hello);This creates a variable called
hellostoring the classic "Hello world" text
(traditionally the first thing written when learning any new programming language).console.log()prints the value to the terminal.Save the file.
โถ๏ธ Step 3: Run the File Using Node
Unlike browser JavaScript (where you'd link the file inside an HTML page and open it in a browser), Node lets you run JavaScript files directly from the terminal.
In the terminal, type:
node index.jsand press Enter.
Important: don't just type
nodeand press Enter alone โ that opens the REPL instead. You must include the filename right afternode.Output:
Hello world!๐ This means you've successfully run your first Node.js script.

๐ง Understanding Node Modules
Node.js can do things browser JavaScript cannot โ like reading and writing files from the computer's file system.
This functionality is not built into plain JavaScript โ it comes from Node modules.
For file operations, Node provides a built-in module called FS (File System).
๐ฅ Importing (Requiring) a Module
To use a module, you require it and store the result in a variable:
const fs = require('fs');require('fs')loads the File System module.The result (an object containing many useful functions for reading/writing files) is stored in the
fsvariable.This
fsvariable will be used in the next step of the course to actually read files.

๐ Learning to Use the Node Documentation
Whenever you need info about a module or function, refer to the official Node.js documentation:

๐ Go to nodejs.org
๐ Click the Documentation tab.

๐ On the left side, you'll see a list of all built-in modules, such as:
๐ฅ๏ธ REPL (used earlier)
๐ File System (fs) (used in this note)
๐ฆ Many others
๐ Reading the Docs
Each module page covers its functions, parameters, and examples.
Example: to read a file, look up
fs.readFileSync()โ we'll use this next.It's okay if the docs feel confusing at first; it'll click as you go.
๐ฏ Key Takeaways
You can write and run standalone
.jsfiles using the command:
node filename.jsNode's extra capabilities (like file handling) come from modules, which you load using
require().The official Node.js documentation is the go-to resource for learning about any built-in module or function.
Next step: Actually use the
fsmodule to read a file from disk usingfs.readFileSync().