The command node --inspect=0.0.0.0:9229 -r ts-node/register apps/some-service/src/main.ts should successfully build the project, which at the certain files, imports the models from the libs/shared/... folder (starting location at the root of the project).
The importing should be done via paths, defined in the main tsconfig.json file.
That would allow me to debug the application in TypeScript (with source maps).
When importing the models in the some-service from libs/shared folder, the NestJS application can not be built with node --inspect=0.0.0.0:9229 -r ts-node/register apps/some-service/src/main.ts anymore.
Error: Cannot find module '@shared/some'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\xxx\apps\some-service\src\app\some-service\some-service.controller.ts:4:1)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Module.m._compile (C:\xxx\node_modules\ts-node\src\index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Object.require.extensions.(anonymous function) [as .ts] (C:\xxx\node_modules\ts-node\src\index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:598:32)
libs/shared/some.model.tstsconfig.json file like this (under compilerOptions):藳json
"paths": {
"@shared/*": ["./libs/shared/*"]
}
````
NODE: 10.13.0
NPM: 6.1.0
"@nrwl/eslint-plugin-nx": "8.7.0",
"@nrwl/jest": "8.7.0",
"@nrwl/nest": "^8.7.0",
"@nrwl/node": "8.7.0",
"@nrwl/workspace": "8.7.0",
"@angular/core": "^8.2.12",
"@nestjs/cli": "^7.0.0",
"@nestjs/common": "^7.0.3",
"@nestjs/core": "^7.0.3",
"@nestjs/platform-express": "^7.0.3",
"@nestjs/swagger": "^4.4.0",
"@nestjs/typeorm": "^6.2.0",
"@nestjs/schematics": "^7.0.0",
"@nestjs/testing": "^7.0.3",
"ts-node": "~7.0.0",
"typescript": "^3.7.2"
````
Please close the issue, it was not related to NX workspace nor NestJS.
What I needed to do, was including the flag to resolve paths in node command: -r tsconfig-paths/register.
Final command: node --inspect=0.0.0.0:9229 -r tsconfig-paths/register" -r ts-node/register apps/search/src/main.ts
Most helpful comment
Please close the issue, it was not related to NX workspace nor NestJS.
What I needed to do, was including the flag to resolve paths in node command:
-r tsconfig-paths/register.Final command:
node --inspect=0.0.0.0:9229 -r tsconfig-paths/register" -r ts-node/register apps/search/src/main.ts