2

I got a angular custom library @foo/bar, which has these dependencies:

"peerDependencies": {
    "@angular/common": "^10.0.14",
    "@angular/core": "^10.0.14"
  },
  "dependencies": {
    "@angular/material": "11.0.1",
    "@ngx-translate/core": "^13.0.0",
    "@ngx-translate/http-loader": "^6.0.0",
    "@custom-library-1": "^0.0.5",
    "@custom-library-2": "^0.0.1",
    "tslib": "^2.0.0"
  },

When I install this library using yarn add @foo/bar in a clean project (with only an empty package.json), and I navigate to node_modules/@angular, I see the folder @angular/material/core.

Now, I'm removing my node_modules and yarn.lock, and I'm adding the following dependencies to this project:

"dependencies": {
    "@angular/animations": "9.1.11",
    "@angular/common": "9.1.11",
    "@angular/compiler": "9.1.11",
    "@angular/core": "9.1.11",
    "@angular/forms": "9.1.11",
    "@angular/material-moment-adapter": "^11.0.1",
    "@angular/platform-browser": "9.1.11",
    "@angular/platform-browser-dynamic": "9.1.11",
    "@angular/router": "9.1.11",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@ngxs/store": "^3.7.0",
    "@nrwl/angular": "9.4.4",
    "@custom-library-1": "^0.0.1",
    "@custom-library-1": "^0.0.5",
    "core-js": "^2.5.4",
    "rxjs": "6.5.5",
    "zone.js": "^0.9.1",
    "@foo/bar": "0.0.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "0.901.9",
    "@angular/cli": "9.1.9",
    "@angular/compiler-cli": "9.1.11",
    "@angular/language-service": "9.1.11",
    "@biesbjerg/ngx-translate-extract": "^4.2.0",
    "@nrwl/cypress": "9.4.4",
    "@nrwl/jest": "9.4.4",
    "@nrwl/workspace": "9.4.4",
    "@types/jest": "25.1.4",
    "@types/node": "~8.9.4",
    "aws-sdk": "^2.585.0",
    "codelyzer": "~5.0.1",
    "cypress": "3.8.2",
    "dotenv": "6.2.0",
    "eslint": "6.8.0",
    "express-serve-static-core": "^0.1.1",
    "jest": "25.2.4",
    "jest-preset-angular": "8.1.3",
    "prettier": "2.0.4",
    "readdir-enhanced": "^5.1.1",
    "ts-jest": "25.2.1",
    "ts-node": "~7.0.0",
    "tslint": "6.0.0",
    "typescript": "3.8.3"
  }

Now when I try to build the project, I'm gettin this error:

ERROR in The target entry-point "@foo/bar" has missing dependencies:
 - @angular/material/core

Also, when I navigate to node_modules/@angular, I notice the entire @angular/material is gone. Anyone knows why and how to solve it?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
coder14
  • 223
  • 1
  • 4
  • 14

1 Answers1

0

I assume that your yarn install command ran through without any issues, otherwise it might be that your installation failed and lead to an incomplete node_modules folder.

I created a project with this setup and don't encounter this issue. This is probably an issue with your tools (yarn, angular cli).

My setup:

Angular CLI 11.0.2 Node: 12.18.2 Yarn 1.22.4

On a side note:

You are creating mix of different Angular versions, which probably doesn't help either, e.g.:

"@angular/material": "11.0.1",
"@angular/common": "^10.0.14",
"@angular/cli": "9.1.9"
code-gorilla
  • 2,231
  • 1
  • 6
  • 21
  • Upgrading angular to the same latest versions did solve another issue, but unfortunately not the one the question is about – coder14 Dec 03 '20 at 10:12