Closed pro100coder closed 1 year ago
Can you get this for me in a git repo, so I can see what's going on? From what I'm seeing here things should be okay, but there may be an environmental factor I'm not aware of like a monorepo setting.
Re-reading the error, it seems like the entities are not being found by the glob you're using. Double check that path and possibly try using the autoLoadEntities
option
Entities are defined normally as I am using migration generation and if there was a problem I would have seen it. I also tried to connect another module from the common library, in it I get an error related to CommandBus from the CQRS package, although all connections and configs are identical to those in the API project
Then can you please provide a minimum reproduction repository?
Yes, please https://github.com/pro100coder/nest-commander-issue1050
For running, you can use this instruction
cd app
yarn install
cd ../cli
yarn install
yarn command:dev import
More than likely, the error comes from having two installs of @nestjs/typeorm
(and other nest packages). They need to be co-installed in the same location, no symlinks, no duplicates, and it should all just work in that case
Hmm, this problem is only in the CLI app, and if I remove the Typeorm package from the app directory, I catch an error
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
../app/src/product/infra/product.module.ts:2:31 - error TS2307: Cannot find module '@nestjs/typeorm' or its corresponding type declarations.
2 import { TypeOrmModule } from '@nestjs/typeorm';
The problem is that this is a monorepo with two node_modules
that both point to @nestjs/typeorm
and likely other nest packages. If you have a monorepo, you have to take a single version package approach by having a coming node_modules
, because of how JS Realms and the instanceof
check works
Is there an existing issue for this?
Current behavior
I have two applications API and CLI with shared logic in library. When I add module to API app everything is working but when I add this module to CLI application(nestjs-commander) I catch the error
Minimum reproduction code
app.module.ts
import.module.ts
product.module.ts
product.entity.ts
Expected behavior
Application works
Package
nest-commander
nest-commander-schematics
nest-commander-testing
Package version
3.12.0
Node.js version
20
In which operating systems have you tested?
Other