Dependency resolution fails with `@mikro-orm/cli` and `pnpm`
See original GitHub issueDescribe 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:
- Created a year ago
- Comments:9 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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).@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