Skip to content

Module resolution: node20 not working in typescript@5.9-beta #62036

Closed
@Shinigami92

Description

@Shinigami92

Demo Repo

faker-js/playground#50

Which of the following problems are you reporting?

Something else more complicated which I'll explain in more detail

Demonstrate the defect described above with a code sample.

neither

    "module": "Node20",
    "moduleResolution": "Node20"

nor

--moduleResolution Node20 --module Node20

seems to work

Run tsc --showConfig and paste its output here

❯ pnpm tsc --moduleResolution node20 --module node20 --showConfig
error TS6046: Argument for '--moduleResolution' option must be: 'node10', 'classic', 'node16', 'nodenext', 'bundler'.

Run tsc --traceResolution and paste its output here

❯ pnpm tsc --moduleResolution node20 --module node20 --traceResolution
error TS6046: Argument for '--moduleResolution' option must be: 'node10', 'classic', 'node16', 'nodenext', 'bundler'.

Paste the package.json of the importing module, if it exists

{
"name": "faker-cjs-test",
"version": "1.0.0",
"private": true,
"type": "commonjs",
"scripts": {
"all": "pnpm run-s build test",
"build": "pnpm run-s build:node10 build:node20 build:bundler",
"build:node10": "tsc",
"build:node20": "tsc --project tsconfig.node20.json --moduleResolution Node20 --module Node20",
"build:bundler": "tsc --project tsconfig.bundler.json",
"test": "pnpm run-s test:js test:ts",
"test:js": "node index.js",
"test:ts": "pnpm run-s test:ts:node10 test:ts:node20 test:ts:bundler",
"test:ts:node10": "tsx index.ts",
"test:ts:node20": "tsx --tsconfig tsconfig.node20.json index.ts",
"test:ts:bundler": "tsx --tsconfig tsconfig.bundler.json index.ts"
}
}

Paste the package.json of the target module, if it exists

{
"name": "faker-cjs-test",
"version": "1.0.0",
"private": true,
"type": "commonjs",
"scripts": {
"all": "pnpm run-s build test",
"build": "pnpm run-s build:node10 build:node20 build:bundler",
"build:node10": "tsc",
"build:node20": "tsc --project tsconfig.node20.json --moduleResolution Node20 --module Node20",
"build:bundler": "tsc --project tsconfig.bundler.json",
"test": "pnpm run-s test:js test:ts",
"test:js": "node index.js",
"test:ts": "pnpm run-s test:ts:node10 test:ts:node20 test:ts:bundler",
"test:ts:node10": "tsx index.ts",
"test:ts:node20": "tsx --tsconfig tsconfig.node20.json index.ts",
"test:ts:bundler": "tsx --tsconfig tsconfig.bundler.json index.ts"
}
}

Any other comments can go here

In https://github.com/faker-js/faker we are drafting a beta v10 which will only expose esm in the future.

For the cjs support, we want to try out the node20 module from ts5.9 as described here https://devblogs.microsoft.com/typescript/announcing-typescript-5-9-beta/#support-for---module-node20

But --moduleResolution node20 --module node20 results in the provided error


extracted out of #61648 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions