Skip to content

Unexpected early exit (code 13) when trying to import {} from a dynamic import() #44601

@brianjenkins94

Description

@brianjenkins94

Version

v18.9.0

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

Also tested in a Linux devcontainer (Linux docker-desktop 5.10.16.3-microsoft-standard-WSL2)

What steps will reproduce the bug?

// package.json

{
  "type": "module",
  "scripts": {
    "start": "node server.js"
  }
}
// server.js

import * as path from "path";
import * as url from "url";

const __filename = url.fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export const BASE_URL = new URL("http://localhost:8080");

const exports = await import(url.pathToFileURL(path.join(__dirname, "index.js")).toString());

console.log(exports); // <-- we never get here
// index.js

// The error appears to be contingent on this import:
import { BASE_URL } from "./server.js";

export async function get(request, response) {
	console.log(BASE_URL);
}

How often does it reproduce? Is there a required condition?

Always.

What is the expected behavior?

The BASE_URL gets console.logd.

What do you see instead?

Unexpected early exit (code 13) on the dynamic import().

No error. Also no error if wrapped in a try...catch.

Additional information

Originating issue: TypeStrong/ts-node#1883

Metadata

Metadata

Assignees

No one assigned

    Labels

    loadersIssues and PRs related to ES module loaders

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions