There is still nothing built-in to provide the exact functionality you describe. However, an alternative to using require it to use the .load command within the REPL, like such:

.load foo.js

It loads the file in line by line just as if you had typed it in the REPL. Unlike require this pollutes the REPL history with the commands you loaded. However, it has the advantage of being repeatable because it is not cached like require.

Which is better for you will depend on your use case.


Edit: It has limited applicability because it does not work in strict mode, but three years later I have learned that if your script does not have 'use strict', you can use eval to load your script without polluting the REPL history:

var fs = require('fs');
eval(fs.readFileSync('foo.js').toString())
Answer from vossad01 on Stack Overflow
🌐
GitHub
github.com › TypeStrong › ts-node › discussions › 2029
How can one `import` an ESM module from REPL? · TypeStrong/ts-node · Discussion #2029
docker run -d --rm -it -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=db -ePOSTGRES_USER=postgres -p 5433:5432 --name pg postgres:14.6-alpine3.17 npm install # 1) This works ... set -a && source ./.env && ts-node src/foo.ts # 2) ... but this, inside ts-node REPL, does NOT: > foo = await import('./...
Author   TypeStrong
Discussions

REPL with ES modules
Search Terms Is there a way to use ts-node REPL with ES modules? Expected Behavior const u = await import('./Util') should work in the REPL when package type is "module" and Types... More on github.com
🌐 github.com
2
November 1, 2022
REPL: import statement inside the Node.js REPL
What is the problem this feature will solve? Allow import statements in REPL What is the feature you are proposing to solve the problem? Instead of: > import assert from 'node:assert' im... More on github.com
🌐 github.com
25
May 20, 2023
I want to test some sequelize models on Node REPL, but I am getting this error, what is the workaround?

have you tried const { Sequelize } = await import('sequelize') ?

More on reddit.com
🌐 r/node
11
7
May 15, 2020
Can't start a REPL
I had a sudden need for a REPL, as I am used to it from Python: ~/W/r/rwdom/domlib master• ↑2 [1] yarn run ts-node --files --esm -T yarn run v1.22.19 $ /home/skrat/Workspace/xxx/yyy/node_modules/.bin/ts-node --files --esm -T > import { Face } from 'src/rw/dom/model/document'; ... More on github.com
🌐 github.com
2
March 26, 2023
🌐
Node.js
nodejs.org › api › cli.html
Command-line API | Node.js v25.2.1 Documentation
The modules which are predefined in the REPL can also be used in script. On Windows, using cmd.exe a single quote will not work correctly because it only recognizes double " for quoting. In Powershell or Git bash, both ' and " are usable. It is possible to run code containing inline types unless the --no-strip-types flag is provided. ... Enable experimental import support for .node ...
🌐
GitHub
github.com › TypeStrong › ts-node › issues › 1924
REPL with ES modules · Issue #1924 · TypeStrong/ts-node
November 1, 2022 - const u = await import('./Util') should work in the REPL when package type is "module" and Typescript is transpiling to ES modules. $ npx ts-node-esm > 2+2 /Users/ckoncz/work/git/csaba/ts-node-esm-examples/<repl>.ts:3 export {}; ^^^^^^ Uncaught SyntaxError: Unexpected token 'export' > 2+2 4 > const u = await import('./Util') Uncaught: TypeError [ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING]: A dynamic import callback was not specified.
Published   Dec 09, 2022
🌐
Node.js
nodejs.org › en › learn › command-line › how-to-use-the-nodejs-repl
Node.js — How to use the Node.js REPL
Note the difference in the outputs of the above two lines. The Node REPL printed undefined after executing console.log(), while on the other hand, it just printed the result of 5 === '5'. You need to keep in mind that the former is just a statement in JavaScript, and the latter is an expression.
🌐
npm
npmjs.com › package › @opentf › react-node-repl
@opentf/react-node-repl - npm
April 7, 2024 - The Node.js REPL in a React component. ... Your site must be served over HTTPS. The following headers must be set in your deployed page. Cross-Origin-Embedder-Policy: require-corp Cross-Origin-Opener-Policy: same-origin Learn more. ... import { NodeREPL } from "@opentf/react-node-repl"; import "@opentf/react-node-repl/lib/style.css"; export default function App() { const code = `console.log("Hello World")`; const deps = ["pkg1", "[email protected]", "pkg3@beta"]; return <NodeREPL code={code} deps={deps} layout="SPLIT_PANEL" />; }
      » npm install @opentf/react-node-repl
    
Published   Apr 07, 2024
Version   0.14.0
Author   Thanga Ganapathy
🌐
OneCompiler
onecompiler.com › nodejs
NodeJS Online Compiler
OneCompiler's NodeJS online editor helps you to write, compile, debug and run NodeJS code online
🌐
Bun
bun.com › modules › node:repl › replserver › definecommand
REPLServer.defineCommand method | Node.js repl module | Bun
3 weeks ago - import repl from 'node:repl'; const replServer = repl.start({ prompt: '> ' }); replServer.defineCommand('sayhello', { help: 'Say hello', action(name) { this.clearBufferedCommand(); console.log(`Hello, ${name}!`); this.displayPrompt(); }, }); ...
Find elsewhere
🌐
GitHub
github.com › nodejs › node › issues › 48084
REPL: import statement inside the Node.js REPL · Issue #48084 · nodejs/node
May 20, 2023 - Uncaught: SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import Instead of: import assert from 'node: assert' use: const assert = await import('node: assert')
Published   May 20, 2023
🌐
Replit
replit.com › templates
Developer Frameworks - Replit
Repls created using developer frameworks currently do not have Agent functionality enabled.
🌐
Reddit
reddit.com › r/node › i want to test some sequelize models on node repl, but i am getting this error, what is the workaround?
I want to test some sequelize models on Node REPL, but ...
May 15, 2020 - Ctrl + Shift + f , type the words, click replace all. And you are done in about 5 seconds maybe ... It definitely took him longer to make this post then to Google the error message and he still hasnt got a solution.
🌐
Replit
replit.com › languages › nodejs
Node.js Online Compiler & Interpreter - Replit
Code, collaborate, compile, run, share, and deploy Node.js and more online from your browser.Sign up to code in Node.js
🌐
Node.js
nodejs.org › api › repl.html
REPL | Node.js v25.2.1 Documentation
The node:repl module provides a Read-Eval-Print-Loop (REPL) implementation that is available both as a standalone program or includible in other applications. It can be accessed using: import repl from 'node:repl';const repl = require('node:repl');copy
🌐
Deno
docs.deno.com › api › node › repl
repl - Node documentation
Node · repl · import * as mod ... not supported. The node:repl module provides a Read-Eval-Print-Loop (REPL) implementation that is available both as a standalone program or includible in other applications....
🌐
GeeksforGeeks
geeksforgeeks.org › node.js › how-to-use-an-es6-import-in-node-js
How To Use An ES6 Import In Node.js? - GeeksforGeeks
July 23, 2025 - NodeJS REPL (READ, EVAL, PRINT, LOOP) 4 min read · Explain V8 engine in Node.js · 7 min read · Node.js Web Application Architecture · 3 min read · NodeJS Event Loop · 5 min read · NodeJS Modules · 5 min read · What are Buffers in Node.js ? 4 min read ·
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-use-the-node-js-repl
How To Use the Node.js REPL | DigitalOcean
March 18, 2022 - The REPL is bundled with every Node.js installation and allows you to quickly test and explore JavaScript code within the Node environment without having to store it in a file.
🌐
TypeScript
typescriptlang.org › play
TS Playground - An online editor for exploring ...
The Playground lets you write TypeScript or JavaScript online in a safe and sharable way.
🌐
Mayank Aggarwal
blogsbymayank.hashnode.dev › mastering-nodejs-a-comprehensive-guide-to-node-js-repl-lesson-1
Mastering NodeJS: A Comprehensive Guide to Node Js REPL|| Lesson - 1
December 28, 2023 - 3.6 Exiting the REPL: Conclusion: Chapter 4: Node Files · 4.1 Reading from Files: 4.2 Writing to Files: 4.3 Checking if a File Exists: 4.4 Working with File Paths: Conclusion: Chapter 5: Process in Node · 5.1 Accessing Command Line Arguments: 5.2 Environment Variables: 5.3 Exiting the Process: 5.4 Event Listeners for Process: Conclusion: Chapter 6: Export in Files · 6.1 Creating a Module: 6.2 Importing the Module: 6.3 Exporting Multiple Functions: 6.4 Exporting Variables: Conclusion: Chapter 7: Export in Directories ·
🌐
GeeksforGeeks
geeksforgeeks.org › node.js › how-to-use-node-js-repl
How to use Node.js REPL ? - GeeksforGeeks
July 23, 2025 - There are a couple of modules in the Node.Js REPL by default. You can get the list by pressing the TAB key twice. If you want to import other modules, you need to follow the following procedure: You need to firstly install the package via the npm package manager for Node.Js.
🌐
GitHub
github.com › TypeStrong › ts-node › issues › 2039
Can't start a REPL · Issue #2039 · TypeStrong/ts-node
March 26, 2023 - I had a sudden need for a REPL, as I am used to it from Python: ~/W/r/rwdom/domlib master• ↑2 [1] yarn run ts-node --files --esm -T yarn run v1.22.19 $ /home/skrat/Workspace/xxx/yyy/node_modules/.bin/ts-node --files --esm -T > import { Face } from 'src/rw/dom/model/document'; ...
Published   Jul 21, 2023