This is my first time using NX and I've found a problem related to NestJS under NX monorepo.
I'm using NX 20.4.2, NestJS 10.0.2 (installed via @nx/nest plugin) and yarn 1 as package manager.
I've installed nest-commander at root directory using yarn add nest-commander
Then inside the NestJS application (in apps/api folder) I've created a script based on NestJS example to run in terminal with nest-commander.
Then inside the apps/api/package.json I've created a scripts entry to a cli.ts file as shown below:
{
...
"scripts": {
"command": "tsx ./src/cli.ts"
},
...
}
Then when I run the following command in the terminal inside apps/api:
yarn command test -n 8
I'm receiving the following error:
/Volumes/kanssd/work/scf-platform/node_modules/nest-commander/src/command.decorators.js:8
Reflect.defineMetadata(metadataKey, options, descriptor.value);
^
TypeError: Cannot read properties of undefined (reading 'value')
at <anonymous> (/Volumes/kanssd/work/scf-platform/packages/nest-commander/src/command.decorators.ts:43:61)
at __decorateElement (/Volumes/kanssd/work/scf-platform/apps/api/src/app/importers/commands/import-file.command.ts:2:2976)
...
And if you pay attention, at path (after the TypeError exception) you will note that path seems wrong:
/Volumes/kanssd/work/scf-platform/packages/nest-commander/src/command.decorators.ts:43:61
It is trying to get the nest-commander package from the packages folder instead the node_modules folder.
Just a note: I've tried to install the nest-commander directly to the apps/api folder and the same error occurs.
Am I doing something wrong?
Thank you in advance.