In my development environment, I have organized a monorepo with two distinct packages. The first package is the primary application, known as app
, while the second package is a shared library that is utilized by the main application, referred to as lib
. Both of these packages are TypeScript/Angular projects.
The framework of my project looks like this:
monorepo/
packages/
app/
lib/
I am currently attempting to configure the app
project in such a way that when an import from the lib
package is detected, instead of searching through the node_modules
directory, it will directly access the output directory generated from building the lib
package. In order to achieve this, I have made alterations in my tsconfig.json
:
{
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es7", "dom"],
"mapRoot": "./",
"module": "es2015",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"paths": {
"lib/*": ["../lib/dist/*"]
}
}
However, upon executing ng build
within the app
folder, I encounter the following error messages (the same error is reported twice, originating from separate locations):
ERROR in node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
../lib/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.
This issue signifies that Angular is being loaded redundantly, once from the app
directory and again from the lib
directory.