-1

Can anyone help with the problem below? I'm stuck in this for 3 days. I really appreciate

I tried many things, but it seems it is getting worse and worse.

I'm trying to build an angular app with ng build --prod, but I'm getting the following error:

ERROR in ./node_modules/ngx-currency/fesm5/ngx-currency.js Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js): TypeError: Cannot read property 'kind' of undefined at isAngularDecoratorMetadataExpression (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:245:35) at checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:70:21) at visitNodes (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15788:30) at Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:16014:24) at checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:61:31) at visitNode (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15779:24) at Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15909:21) at checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:61:31) at visitNode (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15779:24) at Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15966:24) at checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:61:31) at visitNode (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15779:24) at Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15977:24) at checkNodeForDecorators (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\src\transforms\scrub-file.js:61:31) at visitNode (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15779:24) at Object.forEachChild (C:\Users\wagne\Documents\ABC Pneus - Intragroup\app\intragroup-abcpneus-frenteloja - Copia\node_modules@angular-devkit\build-optimizer\node_modules\typescript\lib\typescript.js:15873:21)

My configs are:

tsconfig.json

{
  "compileOnSave": false,
  "angularCompilerOptions": {
    "disableTypeScriptVersionCheck": true
  },
  "compilerOptions": {
    "module": "esnext",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom",
      "ES2017.object"
    ]
  }
}

package.json

{
  "name": "angular-ngrx-course",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve  --proxy-config ./proxy.json",
    "server": "ts-node -P ./server/server.tsconfig.json ./server/server.ts",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/schematics": "^8.0.0",
    "@angular/animations": "^8.0.2",
    "@angular/cdk": "^8.0.0",
    "@angular/common": "^8.0.2",
    "@angular/compiler": "^8.0.2",
    "@angular/core": "^8.0.2",
    "@angular/forms": "^8.0.2",
    "@angular/material": "^8.0.0",
    "@angular/material-moment-adapter": "^8.0.0",
    "@angular/platform-browser": "^8.0.2",
    "@angular/platform-browser-dynamic": "^8.0.2",
    "@angular/router": "^8.0.2",
    "@ngrx/data": "^8.0.1",
    "@ngrx/effects": "^8.0.1",
    "@ngrx/entity": "^8.0.1",
    "@ngrx/router-store": "^8.0.1",
    "@ngrx/store": "^8.0.1",
    "@ngrx/store-devtools": "^8.0.1",
    "body-parser": "^1.18.2",
    "core-js": "^2.4.1",
    "express": "^4.16.2",
    "hammerjs": "^2.0.8",
    "moment": "^2.22.2",
    "rxjs": "^6.3.3",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.800.0",
    "@angular/cli": "^8.0.1",
    "@angular/compiler-cli": "^8.0.2",
    "@angular/language-service": "^8.0.2",
    "@ngrx/schematics": "^8.0.1",
    "@types/express": "^4.0.39",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^5.0.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "^4.1.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^6.0.0",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~3.4.5"
  }
}
Premlatha
  • 1,676
  • 2
  • 20
  • 40
Wagner Vieira
  • 351
  • 4
  • 16

2 Answers2

1

This issue comes in prod build because of incompatible package versions. Its not always a good idea to use the latest available package version, you should try downgrading package versions to resolve these kind of issue.

Check in console which function is failing and which package it belongs to and then try downgrading that package to a stable release version.

lousybear
  • 453
  • 3
  • 12
0

I fixed the problem with not so easy steps.

First I uninstalled and installed the node and npm Right after that I followed the recipe of IAMEVANHE in this link https://github.com/nodejs/node-gyp/issues/119#issuecomment-318609877 to be honest it didn't work at the first time, but I think it might be an important step before the step below. Then I updated angular to version 8. I had to resolve some simple issues with ViewChild, another with modules import.

That's it. I hope it may help others.

Wagner Vieira
  • 351
  • 4
  • 16