microsoft / microsoft/TypeScript

Use explicit extensions in TypeScript's package.json for Node ES resolution compatibility

Open
#44,342 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🕗 Version & Regression Information

Versions:

  • 4.3.2
  • 4.1.2
  • This is a crash
  • This is the behavior in every version I tried
⏯ Playground Link

Minimal repoducible example

💻 Code

Run tsc (yarn tsc, yarn exec tsc, npx tsc, ./node_modules/.bin/tsc) with nodejs flag --experimental-specifier-resolution=node (NODE_OPTIONS="--experimental-specifier-resolution=node" tsc)

🙁 Actual behavior
internal/process/esm_loader.js:74
    internalBinding('errors').triggerUncaughtException(
                              ^

TypeError [ERR_INVALID_MODULE_SPECIFIER]: Invalid module "file:///path/to/project/node_modules/typescript/bin/tsc" 
    at Loader.getFormat (internal/modules/esm/loader.js:117:13)
    at async Loader.getModuleJob (internal/modules/esm/loader.js:242:20)
    at async Loader.import (internal/modules/esm/loader.js:176:17)
    at async Object.loadESM (internal/process/esm_loader.js:68:5) {
  code: 'ERR_INVALID_MODULE_SPECIFIER'
}
🙂 Expected behavior

Build without errors

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting TypeScript's package.json and the tsc entry point shown in node_modules/typescript/bin/tsc, then reproduce the crash with Node's --experimental-specifier-resolution=node flag. Done means the tsc command builds without the reported ERR_INVALID_MODULE_SPECIFIER error in the provided minimal example.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
build-system, cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.