Skip to content

await import() doesn't work in REPL even with --experimental-repl-await #20578

Closed
@fatcerberus

Description

@fatcerberus
  • Version: v10.0.0
  • Platform: Windows 10 Pro 18.03 x64
  • Subsystem: REPL

await import() doesn't work in the REPL even with --experimental-repl-await:

C:\Users\fatce>node --experimental-modules --experimental-repl-await
> (node:4220) ExperimentalWarning: The ESM module loader is experimental.
> await Promise.resolve(812)
812
> await import("module.mjs")
await import("module.mjs")
^^^^^

SyntaxError: await is only valid in async function

I can verify that dynamic import by itself works in the REPL, it's only the await that's an issue:

> import("module.mjs")
Promise {
  <pending>,
  domain:
   Domain {
     domain: null,
     _events:
      { removeListener: [Function: updateExceptionCapture],
        newListener: [Function: updateExceptionCapture],
        error: [Function: debugDomainError] },
     _eventsCount: 3,
     _maxListeners: undefined,
     members: [] } }
> (node:4220) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_URL]: Invalid URL: repl
    at onParseError (internal/url.js:234:17)
    at parse (internal/url.js:243:3)
    at new URL (internal/url.js:318:5)
    at normalizeReferrerURL (internal/process/esm_loader.js:22:10)
    at setImportModuleDynamicallyCallback (internal/process/esm_loader.js:66:37)
    at process._tickCallback (internal/process/next_tick.js:178:7)
(node:4220) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4220) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
\>

Metadata

Metadata

Assignees

No one assigned

    Labels

    experimentalIssues and PRs related to experimental features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions