Giter Site home page Giter Site logo

Comments (9)

B4nan avatar B4nan commented on September 2, 2024 1

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.

B4nan avatar B4nan commented on September 2, 2024

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.

duckies avatar duckies commented on September 2, 2024

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.

B4nan avatar B4nan commented on September 2, 2024

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.

productdevbook avatar productdevbook commented on September 2, 2024

@duckies
"pg": "8.7.3", pg version temporary solution install this

from nestjs.

B4nan avatar B4nan commented on September 2, 2024

"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.

B4nan avatar B4nan commented on September 2, 2024

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.

B4nan avatar B4nan commented on September 2, 2024

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.

bartvanremortele avatar bartvanremortele commented on September 2, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.