I have a problem that is similar to the one described in Building library with imports from another library using NX Monorepo.
Using nx monorepo with a node app and a library. The app is built with @nrwl/js:tsc
(not webpack as it is by default) and then executed using @nrwl/node:node
. This is what the project.json looks like:
"build": {
"executor": "@nrwl/js:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"main": "apps/dep/src/main.ts",
"outputPath": "dist/apps/dep",
"tsConfig": "apps/dep/tsconfig.app.json"
}
},
"serve": {
"executor": "@nrwl/node:node",
"options": {
"buildTarget": "dep:build"
}
},
Importing anything from another library causes a problem with the build due to files not being under rootDir
:
import { MyEnum } from '@zorro/types';
This I resolved using the advice from the question above, adding the following settings to tsconfig.app.json
:
"compilerOptions": {
...
"incremental": false,
"paths": { "@zorro/*": ["dist/libs/*"] }
},
This made tsc work, but when running with node, I get an error:
Error: Cannot find module '@zorro/types'
Can't figure out what needs to be changed in order to properly resolve the path of the library for the compiled main.js
file.