2

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.

theburningfire
  • 481
  • 1
  • 4
  • 20
  • do a `ng serve --prod --sourceMap=true` and you can locally check where it goes wrong – Poul Kruijt Jun 08 '20 at 14:30
  • Check for syntax errors in a call immediately before subscribing, such as a multi-statement arrow function without braces {} – Luciano Jun 08 '20 at 14:33
  • @PoulKruijt i have tried you way and i am getting 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 – theburningfire Jun 08 '20 at 14:44
  • @theburningfire it's difficult to tell where it could go wrong. It does not look like a third party library, because it comes from `main.js`, which means it's your own source code. You should check all your code to make sure you always import `Subscription` from `rxjs`. If it's possible you could share your repository and I (or somebody else) can have a look – Poul Kruijt Jun 08 '20 at 18:11
  • 1
    Check if this question and its answer are useful for you:https://stackoverflow.com/questions/54444516/angular6-prod-build-fails-to-access – Luciano Jun 09 '20 at 06:37

1 Answers1

2

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.

theburningfire
  • 481
  • 1
  • 4
  • 20