Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. scmx created this gist May 10, 2025.
    11 changes: 11 additions & 0 deletions node-repl-start-with-esm-already-imported.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # How to start Node.js repl with some ESM already imported

    `repl.js`
    ```javascript
    import { foo, bar } from './foobar.js'
    import { baz } from './baz.js'
    Object.assign(globalThis, { foo, bar, baz })
    ```

    `node -r ./repl.js`
    Now foo, bar, baz will be available.