Skip to content

REPL: import statement inside the Node.js REPL #48084

Closed as not planned
Closed as not planned
@hemanth

Description

@hemanth

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'
import assert from 'node:assert'
^^^^^^

Uncaught:
SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import

Can we convert them to dynamic import and execute? Just in the REPL.

Like how top level await was supported in Chrome before TLA was an accepted TC39 proposal.

What alternatives have you considered?

At the least we change the message.

from:

Uncaught:
SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import

to:

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')

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.replIssues and PRs related to the REPL subsystem.stale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions