K. Anye
K. Anye

Reputation: 198

How to identify the following problem given by Angular after production build?

I have a large project in Angular and after production build (ng b --prod) and deployment it shows a white page and the following error:

Uncaught TypeError: Object prototype may only be an Object or null: undefined
    at setPrototypeOf (<anonymous>)
    at i (main.5a0de34ba4bae8cec104.js:1)
    at main.5a0de34ba4bae8cec104.js:1
    at Module.zUnb (main.5a0de34ba4bae8cec104.js:1)
    at f (runtime.26209474bfa8dc87a77c.js:1)
    at Object.1 (main.5a0de34ba4bae8cec104.js:1)
    at f (runtime.26209474bfa8dc87a77c.js:1)
    at t (runtime.26209474bfa8dc87a77c.js:1)
    at Array.r [as push] (runtime.26209474bfa8dc87a77c.js:1)
    at main.5a0de34ba4bae8cec104.js:1

I've published a few other projects like this and didn't have this kind of a problem.

Upvotes: 0

Views: 2004

Answers (2)

K. Anye
K. Anye

Reputation: 198

After I updated my project from Angular 7.3.* to Angular 8 and run the following build command

node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod 

I was able to deploy it successfully.

Note: I had to set the maximum budget in angular.json also.

Upvotes: 1

ssuperczynski
ssuperczynski

Reputation: 3426

If you know at which page is the error - follow these steps:

  1. Navigate to angular.json and set sourceMap to true
  2. Navigate to tsconfig.json and enable fullTemplateTypeCheck
  3. run ng build --prod --aot (aot is important here, maybe you'll find this error during compilation)
  4. If no errors, previous step created folder with your build, probably "dist"
  5. Use some library to run "dist" folder. In my case I use http-server.
    Run command http-server ./dist
  6. Navigate to the page where error suppose to be. Now it should be displayed more clearly.

Upvotes: 0

Related Questions