Angular, build failed custom lib do not found another lib,

I have a problem about my angular app,
I create an angular project with two lib inside, one of it have some dependecies from the otherone
project
lib-incas-core
lib-incas

I build them and all work fine and i can create the packages without problem.
I create another project that have an angular application and also a LIB, i include my lib-incas-core and lib-incas in the pakcage.js,
If i build the application all works well, but if i try to build the Library it give me the following error

import { LoggedUser } from ‘incas-web-core’;

../../Lib/Lib20_Web_dev/dist/incas-lib/lib/services/ws-client.service.d.ts:2:40 – error TS2307: Cannot find module ‘incas-web-core’ or its corresponding type declarations.

Here my package.json

{
  "name": "gbm-web-dev",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "buildRPMS": "ng build RPMS",
    "watchRPMS": "ng build  RPMS --watch --configuration development",
    "buildGBS": "ng build GBM_web_dev",
    "build": "npm run buildRPMS && npm run buildGBS",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "15.2.9",
    "@angular/cdk": "15.2.9",
    "@angular/common": "15.2.9",
    "@angular/compiler": "15.2.9",
    "@angular/core": "15.2.9",
    "@angular/forms": "15.2.9",
    "@angular/platform-browser": "15.2.9",
    "@angular/platform-browser-dynamic": "15.2.9",
    "@angular/router": "15.2.9",
    "@casl/ability": "6.5.0",
    "@casl/angular": "8.2.1",
    "@types/lodash": "4.14.199",
    "angular-i18next": "15.0.5",
    "i18next-http-backend": "2.2.2",
    "i18next-multiload-backend-adapter": "2.2.2",
    "i18next-parser": "8.7.0",
    "incas-lib": "file:../../Lib/Lib20_Web_dev/dist/incas-lib",
    "incas-web-core": "file:../../Lib/Lib20_Web_dev/dist/incas-web-core",
    "jest": "29.5.0",
    "lodash": "4.17.21",
    "moment": "2.29.4",
    "primeicons": "6.0.1",
    "primeng": "15.4.1",
    "rxjs": "7.8.1",
    "swagger-typescript-api": "12.0.4",
    "tslib": "2.3.0",
    "zone.js": "0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "15.2.9",
    "@angular-eslint/builder": "15.2.1",
    "@angular-eslint/eslint-plugin": "15.2.1",
    "@angular-eslint/eslint-plugin-template": "15.2.1",
    "@angular-eslint/schematics": "15.2.1",
    "@angular-eslint/template-parser": "15.2.1",
    "@angular/cli": "15.2.6",
    "@angular/compiler-cli": "15.2.9",
    "@types/jasmine": "4.3.0",
    "@types/lodash": "4.14.191",
    "@types/lodash-es": "4.17.7",
    "@typescript-eslint/eslint-plugin": "5.48.1",
    "@typescript-eslint/parser": "5.48.1",
    "eslint": "8.37.0",
    "eslint-config-prettier": "8.10.0",
    "eslint-plugin-prettier": "4.2.1",
    "jasmine-core": "4.5.0",
    "karma": "6.4.0",
    "karma-chrome-launcher": "3.1.0",
    "karma-coverage": "2.2.0",
    "karma-coverage-istanbul-reporter": "3.0.3",
    "karma-firefox-launcher": "2.1.2",
    "karma-jasmine": "5.1.0",
    "karma-jasmine-html-reporter": "2.0.0",
    "karma-remap-istanbul": "0.0.2",
    "karma-requirejs": "1.1.0",
    "karma-teamcity-reporter": "1.1.0",
    "karma-typescript": "5.5.4",
    "karma-webpack": "5.0.0",
    "ng-mocks": "14.11.0",
    "ng-packagr": "15.2.2",
    "nodemon": "2.0.20",
    "typescript": "4.9.4"
  }
}

That the package.json on the lib RPMS (the lib) that is present under the following path:
projects/rpms

  "name": "rpms",
  "version": "0.0.1",
  "peerDependencies": {
    "@angular/common": "15.2.9",
    "@angular/core": "15.2.9",
    "incas-lib": "file:../../../../Lib/Lib20_Web_dev/dist/incas-lib",
    "incas-web-core": "file:../../../../Lib/Lib20_Web_dev/dist/incas-web-core"
  },
  "dependencies": {
    "tslib": "^2.3.0"
  },
  "sideEffects": false
}

And this is the Angular.json file:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "GBM_web_dev": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "preserveSymlinks": true,
            "allowedCommonJsDependencies":[
              "moment",
              "lodash"
            ],
            "outputPath": "dist/gbm-web-dev",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": [
              "zone.js"
            ],
            "tsConfig": "tsconfig.app.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "node_modules/primeicons/primeicons.css",
              "node_modules/primeng/resources/primeng.min.css",
              "node_modules/incas-lib/styles.scss",
              "src/styles.scss"
            ],
            "stylePreprocessorOptions": {
              "includePaths": [
                "src/sass"
              ]
            },
            "vendorChunk": true,
            "aot": true,
            "commonChunk": true,
            "namedChunks": true,
            "progress": true,
            "extractLicenses": true,
            "scripts": []
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "1000kb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "250kb",
                  "maximumError": "500kb"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "buildOptimizer": false,
              "optimization": false,
              "extractLicenses": false,
              "sourceMap": {
                "scripts": true,
                "vendor": true,
                "styles": true
              },
              "namedChunks": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "browserTarget": "GBM_web_dev:build:production"
            },
            "development": {
              "browserTarget": "GBM_web_dev:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "GBM_web_dev:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "polyfills": [
              "zone.js",
              "zone.js/testing"
            ],
            "tsConfig": "tsconfig.spec.json",
            "inlineStyleLanguage": "scss",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          }
        }
      }
    },
    "RPMS": {
      "projectType": "library",
      "root": "projects/rpms",
      "sourceRoot": "projects/rpms/src",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "prefix": "lib",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:ng-packagr",
          "options": {
            
            "project": "projects/rpms/ng-package.json"
          },
          "configurations": {
            "production": {
              "tsConfig": "projects/rpms/tsconfig.lib.prod.json"
            },
            "development": {
              "tsConfig": "projects/rpms/tsconfig.lib.json"
            }
          },
          "defaultConfiguration": "production"
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "tsConfig": "projects/rpms/tsconfig.spec.json",
            "polyfills": [
              "zone.js",
              "zone.js/testing"
            ]
          }
        }
      }
    }
  }
}
 

How can i configure the application to rsolve the error?

I try to import it to another app and all work fine, it seems not work only in the projects/lib build, it

I try to change the TS config and remove the

"paths": {
      "incas-web-core": [
        "dist/incas-web-core"
      ]
    },

and point to the build package but not resolve it, i try to add the path in the per dependencies like you can see in the post but it not seems

 "incas-lib": "file:../../../../Lib/Lib20_Web_dev/dist/incas-lib",
 "incas-web-core": "file:../../../../Lib/Lib20_Web_dev/dist/incas-web-core" 

But seems the build do not consider the new path and use always the

../../Lib/Lib20_Web_dev/dist/incas-lib

i try to add the

"preserveSymlinks": true,

but for the packages is not a valid option

Leave a Comment