Does the Node.js REPL persist code?
No. When you exit the REPL, your code is gone. For anything you want to keep or run repeatedly, use a file. The REPL is for one-off tests and experiments, not for code you want to save.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Node.js REPL vs Running Files: When to Use Each
The Read-Eval-Print Loop. Type node in the terminal, and you can type JavaScript and see results immediately, like a console. It is great for trying APIs, testing expressions, and quick experiments.
Use the REPL for quick experiments, trying APIs, and one-liners. Run files for real scripts, servers, and applications you want to keep, version-control, or run repeatedly. The REPL is a scratchpad; files are for reproducible work.
Save your JavaScript in a file, like app.js, then run node app.js in your terminal. This is for real scripts and applications that you want to keep, version-control, or run repeatedly.
Still have questions?
Browse all our FAQs or reach out to our support team
