It seem I cannot seem to grok NX.
I have 2 packages in a newly integrated NX project.
We have @ici/shared and @ici/project.
@ici/project is a knex migration project, where the migration files use imports of @ici/shared.
Whenever I try to run the knex migration command (knex migrate:up) it says following error:
Cannot find module '@ici/shared'
It seems I'm missing the context, which is available in my paths variable in my tsconfig where knex can resolve @ici/shared. I have already tried to include it in a NX run command with the same error as result. And the nx run-script command with the same error.
Anybody has any suggestions to fix this problem?
I found the answer while writing this question.
It seems Knex has an open issue where it doesn't read the tsconfig resulting in failing to resolve local paths. You can fix this with adding following to the top of the knexfile.ts:
import 'tsconfig-paths/register';
Also ts-node has the same issue