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 resolution errors

See original GitHub issue

I have a NextJs app inside a monorepo. Pacakges are built using Nx

package.json

"dependencies": {
    "@deepkit/type": "^1.0.1-alpha.58",
    [...]
}

Yarn install log

yarn install v1.22.17
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning " > @deepkit/type@1.0.1-alpha.58" has unmet peer dependency "@deepkit/core@^1.0.1-alpha.13".
warning " > @deepkit/type@1.0.1-alpha.58" has unmet peer dependency "reflect-metadata@^0.1.13".
[...]

I try to build

nx build

I get

../../node_modules/@deepkit/type/dist/esm/src/decorators.js
Module not found: Can't resolve '@deepkit/core' in '[path-omitted]\node_modules\@deepkit\type\dist\esm\src'

Looking at the yarn log, I then see that It’s messing a peer dependency to “@deepkit/core@^1.0.1-alpha.13” “reflect-metadata”: “^0.1.13”

So I added those.

Then the build error becomes

Cannot find module '[path-omitted]\node_modules\@deepkit\type\dist\esm\src\types' imported from [path-omitted]\node_modules\@deepkit\type\dist\esm\index.js

Any ideas?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
marcjcommented, Dec 1, 2021

TypeScript’s compiler does not support Node’s default ESM resolution algorithm. They have introduced it in version 4.5 beta https://devblogs.microsoft.com/typescript/announcing-typescript-4-5-beta/#esm-nodejs, but dropped it in the final 4.5 due to issues. To enable the commonly used module resolution algorithm you have to pass to node --experimental-specifier-resolution=node. You can also configure that in your environment variable NODE_OPTIONS=--experimental-specifier-resolution=node. If nextjs supports passing custom node arguments, you can configure it there.

0reactions
JumpLinkcommented, Jul 18, 2022

@productdevbook If nuxt / next uses ESM and the file extensions were the only problem, then yes, but I don’t know if there are other problems, we will see once the PR is merged and a new release is released

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack and TypeScript: module resolution error
[1] [nodemon] app crashed - waiting for file changes before starting... I know this is a common error, but I'm not sure how...
Read more >
Documentation - Module Resolution - TypeScript
Module resolution is the process the compiler uses to figure out what an import refers to. Consider an import statement like import {...
Read more >
Common TypeScript module problems and how to solve them
Enabling the compiler module resolution tracing in TypeScript can provide insight in diagnosing and solving problems.
Read more >
"moduleResolution": "NodeNext" throws ESM related errors ...
I am seeing an issue similar to this where the addition of NodeNext module resolution throws an incorrect error when using it with...
Read more >
Module Resolution - webpack
A resolver is a library which helps in locating a module by its absolute path. A module can be required as a dependency...
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