Move from the page to ordinary files
Download the reading-queue project. It contains the actual model, controller, service, UI, HTML, and automated tests. The in-page preview requires no installation; these steps are for learning how the same project runs outside the course.
- Install a current Node.js LTS release from the official Node site. Node executes JavaScript outside the browser. Its npm tool can run project commands.
- Extract the ZIP. Open a terminal in the extracted folder containing package.json. A terminal runs typed commands in its current folder; it is separate from a JavaScript console editor.
- Run
node --versionto verify installation. Runnpm testto execute the included tests. No npm install is needed: the project uses only Node built-ins. - Run
npm start, leave that terminal open, and visithttp://127.0.0.1:8080. Stop the local server with Ctrl+C. If the port is occupied, the included README explains changing it.
package.json declares type=module so Node interprets .js files as ES modules. Its scripts map npm test to Node’s test runner and npm start to the included server. In "type": "module", type is a package.json configuration field, not an HTML attribute. Each command runs in the folder containing that file. The browser loads app.js as a module from index.html. The server serves only the listed local assets and is not a production hosting setup.
Do not paste terminal commands into a JavaScript editor or double-click the modular index.html. Relative browser modules need the HTTP-served origin. If a module fails, inspect its exact path and export name before changing its logic. Browser developer tools show Console errors and Network requests: open your browser’s Developer Tools menu, select Console or Network, then reload. Paths in Network should refer to the local project.
The tests use node:test to define cases and node:assert/strict for assertions. Inspect one test and its inputs before running it. The runtime is a tool; understanding why a case protects a contract matters more than memorizing a command.
Predict and trace
Write the output before running. Follow the values through each call; if your prediction differs, identify the first step that surprised you.
const scripts = {
test: "node --test project.test.js",
start: "node server.mjs"
};
console.log(scripts.test);
console.log(scripts.start);Check your prediction
node --test project.test.js
node server.mjsThese are strings describing terminal commands, not commands executed by this console example.
Build it yourself
Running Locally: practise
Write projectSummary(files), returning a comma-separated list of .js file names from an array of strings. Use endsWith, a string method that asks whether text has a given ending. Print the two JS files.
const files = ["index.html", "model.js", "app.js", "README.md"];Hint 1: the idea
The project has both source code and supporting files.
Hint 2: a first step
Filter using name.endsWith(“.js”), then join.
Show one solution
function projectSummary(files) {
return files.filter(name => name.endsWith(".js")).join(", ");
}
console.log(projectSummary(["index.html", "model.js", "app.js", "README.md"]));model.js, app.jsRun npm test locally, deliberately break one guarded rule in model.js, and confirm a test fails. Restore the change and rerun. If you stay in the browser, perform the same experiment on a console assertion.
Test a changed requirement
Run npm test locally, deliberately break one guarded rule in model.js, and confirm a test fails. Restore the change and rerun. If you stay in the browser, perform the same experiment on a console assertion.
Explain before moving on
Which environment runs the UI and which runs the tests? What does package.json configure?
Going further
The last project test checks page-lifecycle wiring with a small DOM double. It uses Node’s vm module to run app.js with controlled browser-like objects. That instrumentation is optional reading; you can understand the model and controller tests without learning vm. Browser keyboard and history-navigation checks are still needed for the real UI.
Read Node’s built-in test runner documentation after working through the examples. Use it as a reference when you meet an unfamiliar option; finishing every reference section is not required for this course.
Completion is saved in this browser only. It does not measure mastery.