Comments (9)
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).
from nestjs.
I am not sure if this is something to fix at our end, the dependency definition is looking good to me, pnpm clearly installs multiple @mikro-orm/core
packages, but that itself shouldn't matter here, as you are not using the CLI at all. Note that the same issue is there for any ORM imports, e.g. the EM from core, or even the MikroORM
object. Clearly the @mikro-orm/nestjs
package is resolving to one @mikro-orm/core
package and your app resolves to another.
I mean, we could make the core/knex packages as peer deps for CLI, we do require it to be installed locally anyway, but it feels a bit breaking (global installation of the CLI package would probably fail with some type/import errors).
➜ server git:(master) ✗ pnpm why @mikro-orm/core
Legend: production dependency, optional only, dev only
@test/server /Users/adamek/htdocs/mikro-orm/mikro-orm-cli-issue/packages/server
dependencies:
@mikro-orm/cli 5.3.1
├─┬ @mikro-orm/core 5.3.1
│ └─┬ @mikro-orm/postgresql 5.3.1 peer
│ ├── @mikro-orm/core 5.3.1 peer
│ └─┬ @mikro-orm/knex 5.3.1
│ └── @mikro-orm/core 5.3.1 peer
├─┬ @mikro-orm/knex 5.3.1
│ └─┬ @mikro-orm/core 5.3.1 peer
│ └─┬ @mikro-orm/postgresql 5.3.1 peer
│ ├── @mikro-orm/core 5.3.1 peer
│ └─┬ @mikro-orm/knex 5.3.1
│ └── @mikro-orm/core 5.3.1 peer
└─┬ @mikro-orm/postgresql 5.3.1 peer
├── @mikro-orm/core 5.3.1 peer
└─┬ @mikro-orm/knex 5.3.1
└── @mikro-orm/core 5.3.1 peer
@mikro-orm/core 5.3.1
└─┬ @mikro-orm/postgresql 5.3.1 peer
├── @mikro-orm/core 5.3.1 peer
└─┬ @mikro-orm/knex 5.3.1
└── @mikro-orm/core 5.3.1 peer
@mikro-orm/nestjs 5.1.0
└─┬ @mikro-orm/core 5.3.1 peer
└─┬ @mikro-orm/postgresql 5.3.1 peer
├── @mikro-orm/core 5.3.1 peer
└─┬ @mikro-orm/knex 5.3.1
└── @mikro-orm/core 5.3.1 peer
@mikro-orm/postgresql 5.3.1
├── @mikro-orm/core 5.3.1 peer
└─┬ @mikro-orm/knex 5.3.1
└── @mikro-orm/core 5.3.1 peer
from nestjs.
I have found others online who have similar issues with a myriad of nestjs modules because pnpm can resolve even pinned dependencies to different hashes. I agree trying to resolve this within the mikro-orm ecosystem is unnecessary and I'll close this issue. I will return to using yarn, or at least a package manager with a flat node_modules folder without all of the symlinking.
from nestjs.
A user reported this on slack, and we found out it was caused by depending on wrong version of pg
package (which in fact should not be in the user dependencies at all unless used explicitly - its a transitive dependency of the driver package).
Maybe you had the same problem, will check the repro again to verify. I will have time for this next week probably, lets reopen so we dont forget. Want to give it another try knowing this information, I would very much like to solve this.
from nestjs.
@duckies
"pg": "8.7.3",
pg version temporary solution install this
from nestjs.
"pg": "8.7.3", pg version temporary solution install this
Generally its not about installing this exact version, its about either not installing it at all, or dependeing on the same version as the driver does.
And in this repro I don't see such problem, its quite bare bones... https://github.com/duckies/mikro-orm-cli-issue/blob/master/packages/server/package.json
Maybe its some dependency that is shared with nest.
from nestjs.
Gave this another try, and pnpm is so weird. Only way I was able to make this work was by installing @mikro-orm/knex
explicitly and using that to import SqlEntityManager
.
FYI this is not about the CLI package, I get the same issue if I remove it. To me this sound like a pnpm resolution bug.
from nestjs.
Looks like stating all the ORM packages as peer deps on the nestjs adapter helped - but it works only if I dont install the @mikro-orm/knex
explicitly.
So if you have the @mikro-orm/knex
installed, you need to use that for importing SqlEntityManager
, otherwise it should work with v5.1.2 of the nestjs adapter.
from nestjs.
@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
from nestjs.
Related Issues (20)
- Error when trying to query an entity from the repository HOT 3
- How can I take some actions after it successfully connects or fails? HOT 1
- Cannot persist an entity with a 1-to-1 reference to another entity HOT 5
- Cannot persist Read-Only association HOT 3
- Cannot get `@UseRequestContext` to work in a REQUEST scoped BullMQ processor HOT 4
- Populating Nested Field returns the wrong number of associated entities HOT 5
- Relations not working in nestjs HOT 6
- Issue when running tests after upgrading to 5.2.2
- Bump version, compatible with MikroORM V6 HOT 6
- Nestjs, mikro-orm and postgres can't generate table automatically HOT 2
- vitest + mikroorm collection error HOT 4
- findByCursor method not working on sqlite HOT 1
- Testing with multiple testing modules in NestJS and Jest leads to an error during metadata discovery HOT 2
- Issues running Mikro-ORM with NestJS on Vercel platform HOT 1
- MikroOrmMiddleware not found in e2e tests
- feat: add Transactional Decorator HOT 1
- How to listen to connection status?
- Nest cannot export a provider/module that is not a part of the currently processed module (MikroOrmCoreModule). Please verify whether the exported MongoMikroORM is available in this particular context.
- Allow specifying .fork() options for Request-Scoped EntityManager in the MikroOrmModule
- Using multiple databases hustle
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs.