Stop and restart
An engineer's edit-test loop
⏱ Est. ~4 min
01 · Read
You've probably noticed a pattern: every time you change the code, you have to stop the server and start it again to see the changes.
This is the basic development loop for server-side code:
1. Edit code in a text editor 2. Stop the running server with Ctrl+C 3. Restart with node app.js 4. Test by refreshing the browser 5. Repeat
It might feel annoying, but understanding why matters. When you run node app.js, Node reads the file once and loads it into memory. After that, it runs from memory — it doesn't watch the file for changes. So if you change the file, Node doesn't know until you restart.
💡 Picture thisIt's like reading a recipe before you cook. Once you've read it and start cooking, you follow the version in your head. If someone changes the cookbook while you're cooking, you wouldn't know — you'd have to stop, re-read the recipe, and start over.
Key points
- Ctrl+C stops the running server (sends an interrupt signal)
- Node reads the file once at startup — changes require a restart
- The edit-stop-start-test loop is normal in development
- Static files in public/ (HTML, CSS) may not need a server restart — the browser fetches them again
02 · Quiz
How do you stop a running Node.js server?
- Close the browser
- Type 'stop'
- Press Ctrl+C in the terminal
- Close the terminal window
03 · Read
A heads-up about a tool you'll love later: there's a package called nodemon (short for "node monitor") that watches your files and automatically restarts the server every time you save. It completely eliminates the manual stop-and-restart step.
You install it with npm install -g nodemon, then use nodemon app.js instead of node app.js. Every time you save a change, nodemon picks it up and restarts.
We're not using it now because it's important to understand the manual process. Once you know why a restart is needed, using an automatic tool makes more sense.
04 · Fill in the blank
To stop a running Node.js server in the terminal, press Ctrl+_____.
05 · Checklist
Confirm you understand the development loop. Check off each item once you're confident.
- I can start my server with node app.js
- I can stop it with Ctrl+C
- I know I have to restart after code changes
Other lessons in this chapter
⚠ The full interactive experience needs JavaScript. Please enable it and reload.
※ This is an independent Traditional Chinese teaching project — not an official Anthropic product. Claude™ is a trademark of Anthropic, PBC.