question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module not found for TypeScript 4.7

See original GitHub issue

Expected Behaviour

Able to bundle.

Actual Behaviour

errors such as:

Module not found: Error: Can't resolve './tersible.js'

Steps to Reproduce the Problem

In TypeScript 4.7, the NodeNext module resolution requires the source code to specify the extension as .js. e.g.:

// index.ts
export * from './tersible.js' // for `tersible.ts`

For ts-jest on the jest side, it solves that by doing a transformation:

  moduleNameMapper: {
    '^(\\.{1,2}/.*)\\.js$': '$1',
  },

Maybe something similar is needed? Would be great to add a section in the readme specifically for that.

Location of a Minimal Repository that Demonstrates the Issue.

Not a minimal repo, but here is an example: https://github.com/unional/tersify. Run yarn bundle in the repo

🌷

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:54 (50 by maintainers)

github_iconTop GitHub Comments

2reactions
alexander-akaitcommented, Jul 18, 2022
1reaction
unionalcommented, Jun 15, 2022

https://github.com/justland/just-web/pull/58

One update. After I add the cjs/package.json workaround, at least the CommonJS side resolution is working fine. It’s not directly related to this issue, but it shows that having due-export (CJS + ESM/NodeNext) able to work at the end application.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 4.7
js files are interpreted as ES modules or CommonJS modules, and defaults to CommonJS when not set. When a file is considered an...
Read more >
Typescript cannot find modules that are already installed
I made sure that baseUrl points to the directory node-modules is in so I'm sure the compiler can find node-modules . And just...
Read more >
Announcing TypeScript 4.7 - Microsoft Developer Blogs
Today we're excited to announce the availability of TypeScript 4.7! If you're not yet familiar with TypeScript, it's a language that builds ...
Read more >
Understanding TypeScript 4.7 and ECMAScript module support
The TypeScript 4.7 release comes a major upgrade to ECMAScript module support for Node.js, allowing developers to better support modules.
Read more >
Cannot find module 'X' Error in TypeScript | bobbyhadz
The "Cannot find module or its corresponding type declarations" error occurs when TypeScript cannot locate a third-party or local module in our project....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found