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.

Dependency resolution fails with `@mikro-orm/cli` and `pnpm`

See original GitHub issue

Describe the bug NestJS is unable to resolve SqlEntityManager in a pnpm monorepo only when @mikro-orm/cli is installed.

Stack trace

ERROR [ExceptionHandler] Nest can't resolve dependencies of the AppService (?). Please make sure that the argument SqlEntityManager at index [0] is available in the AppModule context.

Reproduction (duckies/mikro-orm-cli-issue) I created a minimal reproduction that should fail on pnpm i && pnpm dev, but will work once @mikro-orm/cli is removed from the ./packages/server/package.json’s dependencies and commands reran. I also included a yarn@v1 branch and NestJS is working with all dependencies installed.

Additional context I’m unsure if this is an issue with mikro-orm, pnpm, or otherwise. I know pnpm often duplicates, and thus breaks, @nestjs/core, but I don’t think this is the case here.

Versions

Dependency Version
node 16.13.1
typescript 4.7.4
mikro-orm 5.3.1
your-driver postgresql

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
B4nancommented, Aug 15, 2022

It would be indeed good to support pnpm but I am having hard times to even debug this, when going thru the symlinks it looks good to me 🤷 But pnpm why kinda confirms there are two installs.

I was thinking how to get around this, but it all seems semi breaking, so would rather keep that for v6. But we could have the CLI package with only peer deps and change how we import things in that package to not fall apart in case the deps are not there (we just need nice error handling, no special functionality). The mikro-orm metapackage could work the same as e.g. jest CLI - it would depend on the @mikro-orm/cli and prefer its locally installed version (there is an npm package for this).

0reactions
bartvanremortelecommented, Dec 13, 2022

@B4nan I can confirm that importing from the knex package and injecting SqlEntityManager works. In our case the @mikro-orm/knex dependency was not explicitly installed but I still had this exact same issue. It was being pulled in as a dependency of @mikro-orm/postgresql

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lumo fails to resolve its dependencies under pnpm. #1350
I've been working to get ClojureScript working on Glitch, using the Lumo REPL/compiler, which is provided as an npm package and can consume ......
Read more >
Error Codes
A project has a workspace dependency that does not exist in the workspace. For instance, package foo has bar@1.0.0 in the dependencies :...
Read more >
pnpm/resolve-dependencies
Resolves dependency graph of a package. Latest version: 29.0.1, last published: 2 days ago. Start using @pnpm/resolve-dependencies in your ...
Read more >
eslint - pnpm peer dependencies auto-install
hint: If you don't want pnpm to fail on peer dependency issues, set the "strict-peer-dependencies" setting to "false". auto-install-peers = true.
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