Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

o.Subject is not a constructor - Angular 10

Ng serve and ng build --prod command working fine, but when I deploy the app on serve that time below error occurs:-

TypeError: o.Subject is not a constructor
at new e (vendor-esnext.js:1)
at Object.useFactory (vendor-esnext.js:1)
at Object.i [as factory] (vendor-esnext.js:1)
at Xo.hydrate (vendor-esnext.js:1)
at Xo.get (vendor-esnext.js:1)
at Jf.get (vendor-esnext.js:1)
at Object.get (vendor-esnext.js:1)
at Gn (vendor-esnext.js:1)
at Module.Sl (vendor-esnext.js:1)
at Mn.e.ɵfac [as factory] (vendor-esnext.js:1)

tsconfig.base.json

{"compilerOptions": {
"baseUrl": "",
"allowSyntheticDefaultImports": true,
"declaration": false,
"downlevelIteration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
  "dom",
  "es2017"
],
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"target": "ESNext",
"paths": {
  "@angular/*": [
    "node_modules/@angular/*"
  ]
}},"include": [
"src/**/*.ts",
"node_modules/ng4-fittext/*.d.ts"],"exclude": [],"compileOnSave": false,}
like image 788
Jay Senghani Avatar asked Aug 05 '20 10:08

Jay Senghani


1 Answers

The problem will be solved in Angular 10 and later if you replace the import statement of subject as below.

Replace:

import { Subject } from "rxjs/Subject";

with:

import { Subject } from "rxjs";
like image 171
Ahmed Derbala Avatar answered Nov 13 '22 17:11

Ahmed Derbala