ogma icon indicating copy to clipboard operation
ogma copied to clipboard

[Bug]: CLI fails when used inside a project directory that has the latest `@nestjs/common` installed

Open jmcdo29 opened this issue 2 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

When installing and using @ogma/cli inside of a project directory that has @nestjs/common@latest installed, the ogma command exits silently with a status of 1 when ran via a package manager script.

Minimum reproduction code

https://github.com/ohmree/ogma-cli-repro

Steps to reproduce

pnpm i
pnpm ogma
echo $status
1

Expected behavior

We should be able to install @ogma/cli inside a project directory and use it inside a package manager script as well as being able to install it globally and using it via the direct CLI command without getting an error

Package(s) version

  • @ogma/cli: 2.1.6
  • @ogma/nestjs-module: 3.2.0
  • @ogma/platform-express: 3.0.1

Node.js version

16.13.0

In which operating systems have you tested?

  • [ ] macOS
  • [ ] Windows
  • [X] Linux

Other

Messages from Discord

jmcdo29 — Today at 9:46 AM Ah, looks like for some reason @ogma/[email protected] has a pinned version of @nestjs/common and @nestjs/core in the dependencies when they should be peer deps. No idea how that happened, but I'll get a fix up for that later today

omri — Today at 9:46 AM awesome, thanks!

jmcdo29 — Today at 10:04 AM Okay, so I realized why I set it up this way. I wanted the CLI to runnable after a simple npm i -g @ogma/cli (or the yarn and pnpm equiv), so I made hard deps on @nestjs/common and @nestjs/core as nest-commander is going to require them to run. However, that creates a problem when running it inside of a project that has differing @nestjs/ packages. Let me see if I can resolve the issues in the repro and find a way to make this work as is

omri — Today at 10:05 AM in the meanwhile, would installing the exact version of nestjs @ogma/cli uses help?

jmcdo29 — Today at 10:05 AM Yeah, you should be able to downgrade to 8.4.0 I think.

omri — Today at 10:09 AM eh, couldn't get that to work and it's annoying to fiddle with i'll just wait for a fix aaaand i got it to work thanks 🙂

jmcdo29 — Today at 10:13 AM What did you end up doing? I may need to document this about the CLI

omri — Today at 10:15 AM hard-pinned anything nestjs-related that used the same version number as @nestjs/core to "8.4.0", no caret

jmcdo29 — Today at 10:16 AM Had a feeling that would be the "solution" I'll fiddle with some peerDep configs and see if I can make it use the existing package and if not install the required deps

jmcdo29 — Today at 10:46 AM Another option in the meantime is to install the @ogma/cli package globally and then use ogma as a direct command. I'll still work on fixing this, just thought I'd mention the other option

jmcdo29 — Today at 4:33 PM All right, so definitely realized this is not near as straightforward as I initially though, because the @ogma/cli needs to be able to be installed globally as well as inside an project directory. When inside a project directory, the @ogma/cli package needs to be using peerDeps for the @nestjs/ packages, but when installed globally it should use dependencies. Very tricky to figure this out. I'll create an issue using your minimum reproduction as the repro repo and put updates there as I figure things out so we can track this better

jmcdo29 avatar Apr 05 '22 23:04 jmcdo29