How can I "debug" a failed build on production mode

Discussão em 'Angular' iniciado por Eleuis, Dezembro 16, 2024.

  1. Eleuis

    Eleuis Guest

    The project uses Angular 10 and Node 12.22.12

    When I try to build my project on development mode (ng build --watch) it runs fine and everything works correctly. However, when I run it on prod mode (ng build --prod) I get the following error log:

    [error] TypeError: C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\polyfills-es5.748d34bf10a6f26b2d67.js: Cannot read property 'params' of undefined
    at NodePath._getKey (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\path\family.js:244:25)
    at NodePath.get (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\path\family.js:237:20)
    at Object.Function (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\scope\index.js:271:25)
    at _traverse (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\scope\traverseForScope.js:37:17)
    at traverseForScope (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\scope\traverseForScope.js:19:3)
    at Scope.crawl (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\scope\index.js:658:35)
    at Scope.init (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\scope\index.js:626:12)
    at NodePath.setScope (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\path\context.js:141:53)
    at NodePath.setContext (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\path\context.js:153:12)
    at NodePath.popContext (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\path\context.js:205:10)
    at TraversalContext.visitQueue (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\context.js:102:27)
    at TraversalContext.visitSingle (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\context.js:66:19)
    at TraversalContext.visit (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\context.js:113:19)
    at traverseNode (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\traverse-node.js:22:17)
    at traverse (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\traverse\lib\index.js:53:34)
    at transformFile (C:\Users\[redacted-username]\[redacted-path]\Exploration\src\Exploration\Web\Client-App\exploration\node_modules\@babel\core\lib\transformation\index.js:107:29)



    The error Cannot read property 'params' of undefined is as generic as it gets, and since I am not using the @babel/traverse library myself (I suppose it's a sub-dependency of a lib that I do use) I can't figure out the error.

    I generated the sourceMap of the build but I can't get any useful information out of it.

    One thing I noticed, the polyfil file that gets generated has a different name than the error suggests, in case of this particular build it's polyfills-es2015.532602ff2bab781a398b vs the polyfills-es5.748d34bf10a6f26b2d67.js suggested by the log file)

    This is my angular configuration:

    {
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
    "exploration": {
    "projectType": "application",
    "schematics": {
    "@schematics/angular:component": {
    "style": "scss"
    }
    },
    "root": "",
    "sourceRoot": "src",
    "prefix": "app",
    "architect": {
    "build": {
    "builder": "@angular-devkit/build-angular:browser",
    "options": {
    "outputPath": "../../../wwwroot/dist/exploration",
    "index": "src/index.html",
    "main": "src/main.ts",
    "polyfills": "src/polyfills.ts",
    "tsConfig": "tsconfig.app.json",
    "aot": true,
    "assets": [
    "src/assets",
    "src/assets/*",
    "src/app/images"
    ],
    "styles": [
    "node_modules/bootstrap/dist/css/bootstrap.min.css",
    "src/styles.scss"
    ],
    "scripts": [],
    "allowedCommonJsDependencies": [
    "@ahryman40k/ts-fhir-types"
    ]
    },
    "configurations": {
    "production": {
    "fileReplacements": [
    {
    "replace": "src/environments/environment.ts",
    "with": "src/environments/environment.prod.ts"
    }
    ],
    "optimization": true,
    "outputHashing": "all",
    "sourceMap": true,
    "extractCss": true,
    "namedChunks": false,
    "extractLicenses": true,
    "vendorChunk": false,
    "buildOptimizer": true,
    "budgets": [
    {
    "type": "initial",
    "maximumWarning": "20mb",
    "maximumError": "50mb"
    },
    {
    "type": "anyComponentStyle",
    "maximumWarning": "60kb",
    "maximumError": "100kb"
    }
    ]
    }
    }
    },
    "serve": {
    "builder": "@angular-devkit/build-angular:dev-server",
    "options": {
    "browserTarget": "exploration:build"
    },
    "configurations": {
    "production": {
    "browserTarget": "exploration:build:production"
    }
    }
    },
    "extract-i18n": {
    "builder": "@angular-devkit/build-angular:extract-i18n",
    "options": {
    "browserTarget": "exploration:build"
    }
    },
    "test": {
    "builder": "@angular-devkit/build-angular:karma",
    "options": {
    "main": "src/test.ts",
    "polyfills": "src/polyfills.ts",
    "tsConfig": "tsconfig.spec.json",
    "karmaConfig": "karma.conf.js",
    "assets": [
    "src/favicon.ico",
    "src/assets",
    "src/assets/*",
    "src/app/images"
    ],
    "styles": [
    "node_modules/bootstrap/dist/css/bootstrap.min.css",
    "src/styles.scss"
    ],
    "scripts": []
    }
    },
    "lint": {
    "builder": "@angular-devkit/build-angular:tslint",
    "options": {
    "tsConfig": [
    "tsconfig.app.json",
    "tsconfig.spec.json",
    "e2e/tsconfig.json"
    ],
    "exclude": [
    "**/node_modules/**"
    ]
    }
    },
    "e2e": {
    "builder": "@angular-devkit/build-angular:protractor",
    "options": {
    "protractorConfig": "e2e/protractor.conf.js",
    "devServerTarget": "exploration:serve"
    },
    "configurations": {
    "production": {
    "devServerTarget": "exploration:serve:production"
    }
    }
    }
    }
    }},
    "defaultProject": "exploration"
    }



    Even though I am currently using Angular 10, and if it's not much of a hassle, I'd like to know how to "debug" this on more recent versions too, since I am also working on several A17 projects.

    Continue reading...

Compartilhe esta Página