angularng-packagr

Angular 12 build package error without any detail


I have an Angular 12 library project that built fine in the past (year or two ago), but now it is failing. The only output I'm seeing is as follows:

Building Angular Package
moduleName.startsWith is not a function

There is no code in the project that even uses startsWith, so I'm at a loss as to what the problem is. The other thing that is making this difficult is the inability to get any further detail on the actual problem (--verbose switch for ng build does not work).

Is anyone aware of how I can get more build debug info so I can actually diagnose the issue?

Update - Below is the package.json:

{
  "name": "@our-org/our-package",
  "version": "12.3.1",
  "license": "UNLICENSED",
  "repository": {
    "type": "git",
    "url": "https://github.com/our-org/our-repo.git"
  },
  "publishConfig": {
    "registry": "https://npm.pkg.github.com"
  },
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build:prod": "ng build our-pkg-lib --configuration production && npm run build-styles",
    "build": "ng build our-pkg-lib && npm run build-styles",
    "build-styles": "cpx \"./projects/our-pkg-lib/src/lib/styles/**/*\" \"./dist/our-pkg-lib/styles\"",
    "test": "ng test",
    "lint": "ng lint --fix --format stylish",
    "e2e": "ng e2e",
    "lint-staged": "lint-staged",
    "tslint-check": "tslint-config-prettier-check ./tslint.json",
    "watch": "ng build our-pkg-lib --configuration production --watch",
    "publish-lib": "npm run build:prod && npm publish dist/our-pkg-lib/",
    "prepare": "cd .. && husky install"
  },
  "private": false,
  "devDependencies": {
    "@agm/core": "^3.0.0-beta.0",
    "@angular-devkit/build-angular": "^12.2.13",
    "@angular/animations": "^12.2.13",
    "@angular/cdk": "^12.2.12",
    "@angular/cli": "^12.2.13",
    "@angular/common": "^12.2.13",
    "@angular/compiler": "^12.2.13",
    "@angular/compiler-cli": "^12.2.13",
    "@angular/core": "^12.2.13",
    "@angular/forms": "^12.2.13",
    "@angular/language-service": "^12.2.13",
    "@angular/material": "^12.2.12",
    "@angular/platform-browser": "^12.2.13",
    "@angular/platform-browser-dynamic": "^12.2.13",
    "@angular/router": "^12.2.13",
    "@our-org/another-internal-pkg": "^12.1.0",
    "@types/googlemaps": "^3.43.3",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "^2.0.10",
    "@types/json-logic-js": "^1.2.1",
    "@types/node": "^20.2.5",
    "@types/uuid": "^9.0.1",
    "codelyzer": "^6.0.2",
    "core-js": "^3.19.1",
    "cpx": "^1.5.0",
    "flexboxgrid": "^6.3.1",
    "hammerjs": "^2.0.8",
    "husky": "^7.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "jquery": "^3.6.0",
    "json-logic-js": "^2.0.1",
    "karma": "^6.3.7",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.7.0",
    "lint-staged": "^10.5.4",
    "moment": "^2.29.1",
    "ng-packagr": "^12.2.7",
    "ngx-mask": "^9.1.4",
    "ngx-trumbowyg": "^6.0.7",
    "postcss": "^8.3.11",
    "pre-commit": "^1.2.2",
    "prettier": "^2.4.1",
    "prettier-plugin-organize-imports": "^2.3.4",
    "pretty-quick": "^2.0.2",
    "protractor": "~7.0.0",
    "rxjs": "^7.4.0",
    "scss-bundle": "^3.1.2",
    "stylelint": "^13.13.1",
    "trumbowyg": "^2.21.0",
    "ts-node": "^10.9.1",
    "tslib": "^2.3.1",
    "tslint": "^6.1.3",
    "tslint-config-prettier": "^1.18.0",
    "typescript": "^4.3.5",
    "uuid": "^8.3.2",
    "zone.js": "~0.11.4"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.ts": [
      "tslint --fix",
      "pretty-quick --staged"
    ],
    "*.{css,scss,json,md,html}": [
      "pretty-quick --staged"
    ]
  }
}

Solution

  • After a lot of additional searching, I was able to resolve my build issue with the following steps: