Search code examples
javascriptangularproductionng-build

How to resolve the given error by Angular after production build(Subscription is not defined)?


I have a angular app that runs fine in ng build and served to my ASP.net core web server, but when i build the same application by ng build --prod command the project build successfully but when i serve my wwwroot folder in web server i am getting this error:-

Uncaught ReferenceError: Subscription is not defined
at Module.zUnb (main.2fbc30c2b70c6b016365.js:1)
at f (runtime.8844839a3cc2e01b8d02.js:1)
at Object.0 (main.2fbc30c2b70c6b016365.js:1)
at f (runtime.8844839a3cc2e01b8d02.js:1)
at t (runtime.8844839a3cc2e01b8d02.js:1)
at Array.r [as push] (runtime.8844839a3cc2e01b8d02.js:1)
at main.2fbc30c2b70c6b016365.js:1

and nothing appears on webpage. I have read about this on web but cannot resolved this error. What could be the reason for this error or how can i solve this. Please dont mind i have recently start with web development.Thankyou.

Update 1 : Upon running ng serve --prod sourceMap=true getting this error :-

Uncaught ReferenceError: Subscription is not defined at 
Module.zUnb (SubjectSubscription.js.pre-build-optimizer.js:7) 
at f (bootstrap:78) 
at Object.0 (main.b3059a947fcd0e8a64b5.js:1) 
at f (bootstrap:78) 
at t (bootstrap:45) 
at Array.r [as push] (bootstrap:32) 
at main.b3059a947fcd0e8a64b5.js:1

Update 2 : With ng serve --prod sourceMap=true command this extra warning is comming :-

enter image description here

Is the warning has something to do with my error. Also i have checked for subscription in my code their doesn't seems any error.


Solution

  • I found the answer to this problem in Luciano comment.

    Angular6 - Prod build fails to access

    Basically it was Rxjs package problem in package.json.

    May be this may help someone. Thankyou.