Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular - cannot find error source because stack trace is obfuscated in production mode

Tags:

angular

I tried to run angular app in production mode ng serve --aot --prod. When the app is launched, I see an error in console, but the error stack trace is obfuscated and I cannot find the source code which causes the error. Without --prod option, there are no errors. How I can find the error source?

main.026c3ce7721e9ba03a1e.js:1 ERROR TypeError: f.ngOnInit is not a function
    at main.026c3ce7721e9ba03a1e.js:1
    at main.026c3ce7721e9ba03a1e.js:1
    at Ji (main.026c3ce7721e9ba03a1e.js:1)
    at Eo (main.026c3ce7721e9ba03a1e.js:1)
    at Object.updateDirectives (main.026c3ce7721e9ba03a1e.js:1)
    at Object.updateDirectives (main.026c3ce7721e9ba03a1e.js:1)
    at $i (main.026c3ce7721e9ba03a1e.js:1)
    at so (main.026c3ce7721e9ba03a1e.js:1)
    at oo (main.026c3ce7721e9ba03a1e.js:1)
    at $i (main.026c3ce7721e9ba03a1e.js:1)
like image 807
Valeriy Katkov Avatar asked Mar 09 '26 06:03

Valeriy Katkov


1 Answers

Enable sourceMap in anuglar.json config file to see original code stack trace.

{
  "projects": {
    "myProject": {
      "architect": {
        "build": {
          "configurations": {
            "production": {
              "sourceMap": true
            }
          }
        }
      }
    }
  }
}

I also tried to add --source-map option to serve command, but the option didn't solve my problem for some reason.

like image 61
Valeriy Katkov Avatar answered Mar 11 '26 07:03

Valeriy Katkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!