Skip to content

Cannot find module when explicit import extension #1494

@loynoir

Description

@loynoir

Search Terms

Why explicit extension

Explicit import extension seems the ONLY convenient way to write dual module in typescript, supported by tsc.

Expected Behavior

$ ts-node a.ts
42

Actual Behavior

$ ts-node a.ts
Error: Cannot find module './b.js'

Steps to reproduce the problem

Minimal reproduction

// a.ts
import b from './b.js'
console.log(b)
// b.ts
export default 42

Specifications

  • ts-node version:
  • node version:
  • TypeScript version:
  • tsconfig.json, if you're using one:
{}
  • Operating system and version:
  • If Windows, are you using WSL or WSL2?:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions