Skip to content

Angular 5 production build issue #20095

Closed

Description

@aishanu

ERROR in ./node_modules/rxjs/_esm5/observable/BoundNodeCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined at Object.getEffectiveTypeAnnotationNode (node_modules/typescript/lib/typescript.js:9341:17).

at Object.forEach (/home/arpitha/Desktop/itrack-new/itrack-app/node_modules/typescript/lib/typescript.js:1506:30)
@ ./node_modules/rxjs/_esm5/observable/bindCallback.js 2:0-68
@ ./node_modules/rxjs/_esm5/add/observable/bindCallback.js
@ ./node_modules/rxjs/_esm5/Rx.js
@ ./src/app/service/interceptor.service.ts
@ ./src/app/app.module.ngfactory.js
@ ./src/main.ts
@ multi ./src/main.ts

Activity

  1. aishanu commented on Nov 2, 2017

    @aishanu
    Author

    I am getting prodction build issue after upgrading to Angular v5

  2. HeroBart commented on Nov 2, 2017

    @HeroBart

    Look for import { Observable } from 'rxjs/Rx' in your project and replace it with import { Observable } from 'rxjs/Observable'

  3. Toxicable commented on Nov 2, 2017

    @Toxicable

    Hello, we reviewed this issue and determined that it doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag angular.

    If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation.

  4. rsaenen commented on Nov 8, 2017

    @rsaenen

    I had the same issue and I looked for all import from rxjs.

    • Observable
    • Subject
    • Subscription
    • ...

    Ctrl+F for import { x } from 'rxjs/' or import { x } from 'rxjs/Rx'

  5. Anoop-Goudar commented on Nov 9, 2017

    @Anoop-Goudar

    Updating typescript to 2.6.1 will fix this issue, but we will have warning message as below

    @angular/[email protected] requires typescript@'>=2.4.2 <2.5.0' but 2.6.1 was found instead.
    Using this version can result in undefined behaviour and difficult to debug problems.
    
    Please run the following command to install a compatible version of TypeScript.
    
        npm install typescript@'>=2.4.2 <2.5.0'
    
    To disable this warning run "ng set warnings.typescriptMismatch=false".
    
  6. lukestayreal commented on Nov 9, 2017

    @lukestayreal

    this solve my issue~~!!

  7. sondreb commented on Nov 10, 2017

    @sondreb

    I can also confirm that using the bindCallback operator on Observable will cause production build errors, unless TypeScript is upgraded above the "supported" version. It is not enough to simply upgrade global TypeScript to 2.6.1, also make sure you upgrade package.json or it won't work.

    // Import example
    import 'rxjs/add/observable/bindCallback';
    
    // TypeScript example
    Observable.bindCallback()
    
  8. klochko7 commented on Nov 13, 2017

    @klochko7

    I have the same error .. I am using .. Should I import import "rxjs" ?

    import { timeout } from 'rxjs/operator/timeout';
    import { map } from 'rxjs/operator/map';
    
    
    Error: ./node_modules/rxjs/observable/BoundNodeCallbackObservable.js
    Module build failed: TypeError: Cannot read property 'type' of undefined
        at Object.getEffectiveTypeAnnotationNode (D:\tmp\ionic2\ezpart-mobile-svn\no
    de_modules\typescript\lib\typescript.js:9341:17)
        at assignContextualParameterTypes (D:\tmp\ionic2\ezpart-mobile-svn\node_modu
    les\typescript\lib\typescript.js:41652:25)
        at checkFunctionExpressionOrObjectLiteralMethod (D:\tmp\ionic2\ezpart-mobile
    -svn\node_modules\typescript\lib\typescript.js:41948:29)
        at checkExpressionWorker (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\types
    cript\lib\typescript.js:42959:28)
        at checkExpression (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\
    lib\typescript.js:42898:42)
        at checkExpressionCached (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\types
    cript\lib\typescript.js:42779:38)
        at checkReturnStatement (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typesc
    ript\lib\typescript.js:45418:54)
        at checkSourceElement (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescri
    pt\lib\typescript.js:46763:28)
        at Object.forEach (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\l
    ib\typescript.js:1506:30)
        at checkBlock (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\lib\t
    ypescript.js:44563:16)
     @ ./node_modules/rxjs/observable/bindNodeCallback.js 2:36-76
     @ ./node_modules/rxjs/add/observable/bindNodeCallback.js
     @ ./node_modules/rxjs/Rx.js
     @ ./src/providers/loginProvider.ts
     @ ./src/app/app.module.ngfactory.js
     @ ./src/app/main.ts,./node_modules/rxjs/observable/BoundCallbackObservable.js
    Module build failed: TypeError: Cannot read property 'type' of undefined
        at Object.getEffectiveTypeAnnotationNode (D:\tmp\ionic2\ezpart-mobile-svn\no
    de_modules\typescript\lib\typescript.js:9341:17)
        at assignContextualParameterTypes (D:\tmp\ionic2\ezpart-mobile-svn\node_modu
    les\typescript\lib\typescript.js:41652:25)
        at checkFunctionExpressionOrObjectLiteralMethod (D:\tmp\ionic2\ezpart-mobile
    -svn\node_modules\typescript\lib\typescript.js:41948:29)
        at checkExpressionWorker (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\types
    cript\lib\typescript.js:42959:28)
        at checkExpression (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\
    lib\typescript.js:42898:42)
        at checkExpressionCached (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\types
    cript\lib\typescript.js:42779:38)
        at checkReturnStatement (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typesc
    ript\lib\typescript.js:45418:54)
        at checkSourceElement (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescri
    pt\lib\typescript.js:46763:28)
        at Object.forEach (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\l
    ib\typescript.js:1506:30)
        at checkBlock (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\typescript\lib\t
    ypescript.js:44563:16)
     @ ./node_modules/rxjs/observable/bindCallback.js 2:32-68
     @ ./node_modules/rxjs/add/observable/bindCallback.js
     @ ./node_modules/rxjs/Rx.js
     @ ./src/providers/loginProvider.ts
     @ ./src/app/app.module.ngfactory.js
     @ ./src/app/main.ts
        at BuildError.Error (native)
        at new BuildError (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\@ionic\app-s
    cripts\dist\util\errors.js:16:28)
        at callback (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\@ionic\app-scripts
    \dist\webpack.js:121:28)
        at emitRecords.err (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\webpack\lib
    \Compiler.js:269:13)
        at Compiler.emitRecords (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\webpac
    k\lib\Compiler.js:375:38)
        at emitAssets.err (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\webpack\lib\
    Compiler.js:262:10)
        at applyPluginsAsyncSeries1.err (D:\tmp\ionic2\ezpart-mobile-svn\node_module
    s\webpack\lib\Compiler.js:368:12)
        at next (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\tapable\lib\Tapable.js
    :218:11)
        at Compiler.compiler.plugin (D:\tmp\ionic2\ezpart-mobile-svn\node_modules\we
    bpack\lib\performance\SizeLimitsPlugin.js:99:4)
        at Compiler.applyPluginsAsyncSeries1 (D:\tmp\ionic2\ezpart-mobile-svn\node_m
    odules\tapable\lib\Tapable.js:222:13)
    
  9. lincolnthree commented on Nov 13, 2017

    @lincolnthree
    Contributor

    @Anoop-Goudar Upgrading to TypeScript 2.6.1 also solved my issue. Thank you.

  10. subatomicglue commented on Nov 13, 2017

    @subatomicglue

    When using typescript 2.6.1 with ng serve --aot, I get this error when incrementally saving a .html or .ts file
    (Which the fix here says to downgrade to typescript 2.4.2...)

    ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
        at tryReuseStructureFromOldProgram (.../node_modules/typescript/lib/typescript.js:72100:26)
        at Object.createProgram (.../node_modules/typescript/lib/typescript.js:71808:34)
        at AngularCompilerProgram._updateProgramWithTypeCheckStubs (.../node_modules/@angular/compiler-cli/src/transformers/program.js:461:30)
        at .../node_modules/@angular/compiler-cli/src/transformers/program.js:149:23
        at process._tickCallback (internal/process/next_tick.js:103:7)
    

    When using typescript 2.4.2 with ng build -prod, I get the error described above.
    (Which the fix here says to upgrade typescript to 2.6.1.)

    ERROR in ./node_modules/rxjs/_esm5/observable/BoundNodeCallbackObservable.js
    Module build failed: TypeError: Cannot read property 'type' of undefined at Object.getEffectiveTypeAnnotationNode (node_modules/typescript/lib/typescript.js:9341:17).
    

    So I am in a catch 22, where I need typescript 2.4.2 for ng serve --aot and typescript 2.6.1 for ng build --prod.

  11. finalxcode commented on Nov 17, 2017

    @finalxcode

    my problem is ngx-datatable, after upgrade ngx-datatable to 11.0.4, i works swimlane/ngx-datatable#1104 (comment)

  12. bastienlemaitre commented on Nov 23, 2017

    @bastienlemaitre

    Works with Typescript 2.4.2, i have replaced

    import { Observable } from 'rxjs/Rx';

    by

    import { Observable } from 'rxjs/Observable';
  13. maiziheimei commented on Nov 23, 2017

    @maiziheimei

    Yes, it solved by updating typescript's version

    **For Exact version
    npm install [email protected] --save
    **For latest release
    npm install typescript@latest --save

  14. sburnicki commented on Nov 23, 2017

    @sburnicki

    I had this error when using

    import {pipe} from "rxjs/Rx";`

    and needed to change it to

    import {pipe} from "rxjs/util/pipe";
  15. 1 remaining item

  16. bastienlemaitre commented on Nov 24, 2017

    @bastienlemaitre

    You need to import operators.

  17. iursevla commented on Nov 25, 2017

    @iursevla

    @bastienlemaitre
    how so? (Sorry if it's a noob question)

    import { Operator } from 'rxjs/Operator'; ?? and then?

  18. iursevla commented on Nov 28, 2017

    @iursevla

    I solved it by importing the operator as @bastienlemaitre said.
    Like so:

    import { BehaviorSubject } from 'rxjs/BehaviorSubject';
    import 'rxjs/add/operator/first';
  19. giscafer commented on Nov 30, 2017

    @giscafer

    I solved it by updating latest vesion

    "@ionic/app-scripts": "^3.1.4",
    "typescript": "^2.6.2",

    and import { x } from 'rxjs' replace width import { x } from 'rxjs/Rx'

  20. subatomicglue commented on Nov 30, 2017

    @subatomicglue

    With typescript 2.6.2, I still get the error when using ng serve --aot. It compiles perfectly the first time. Then when I save a .ts or .html file, I get this error:

    ERROR in Error: Debug Failure. False expression: Host should not return a redirect source file from `getSourceFile`
        at tryReuseStructureFromOldProgram (.../node_modules/typescript/lib/typescript.js:72296:26)
        at Object.createProgram (.../node_modules/typescript/lib/typescript.js:72004:34)
        at AngularCompilerProgram._updateProgramWithTypeCheckStubs (.../node_modules/@angular/compiler-cli/src/transformers/program.js:461:30)
        at .../node_modules/@angular/compiler-cli/src/transformers/program.js:149:23
        at process._tickCallback (internal/process/next_tick.js:103:7)
    
  21. PixeliGer commented on Dec 12, 2017

    @PixeliGer

    This is my project config:

    ❯ ng -v
    
        _                      _                 ____ _     ___
       / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
      / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
     / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
    /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                   |___/
    
    Angular CLI: 1.5.4
    Node: 6.11.4
    OS: darwin x64
    Angular: 5.0.3
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, platform-server, router
    
    @angular/cli: 1.5.4
    @angular-devkit/build-optimizer: 0.0.33
    @angular-devkit/core: 0.0.21
    @angular-devkit/schematics: 0.0.37
    @ngtools/json-schema: 1.1.0
    @ngtools/webpack: 1.8.4
    @schematics/angular: 0.1.7
    typescript: 2.4.2
    webpack: 3.8.1 
    

    I just removed or replaced every unnecesary or unnused 'rxjs' import in my project but the error persist:

    Module build failed: TypeError: Cannot read property 'type' of undefined
        at Object.getEffectiveTypeAnnotationNode (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:9341:17)
        at assignContextualParameterTypes (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:41652:25)
        at checkFunctionExpressionOrObjectLiteralMethod (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:41948:29)
        at checkExpressionWorker (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:42959:28)
        at checkExpression (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:42898:42)
        at checkExpressionCached (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:42779:38)
        at checkReturnStatement (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:45418:54)
        at checkSourceElement (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46763:28)
        at Object.forEach (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:1506:30)
        at checkBlock (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:44563:16)
        at checkSourceElement (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46742:28)
        at checkFunctionExpressionOrObjectLiteralMethodDeferred (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:41990:21)
        at checkDeferredNodes (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46828:25)
        at checkSourceFileWorker (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46863:17)
        at checkSourceFile (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46842:13)
        at Object.forEach (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:1506:30)
     @ ./node_modules/rxjs/_esm5/observable/bindNodeCallback.js 2:0-76
     @ ./node_modules/rxjs/_esm5/add/observable/bindNodeCallback.js
     @ ./node_modules/rxjs/_esm5/Rx.js
     @ ./node_modules/angular2-datatable/lib/DataTable.js
     @ ./src/app/shared/tables/staff-table/staff-table.component.ngfactory.js
     @ ./src/app/components/staff/staff-list.component.ngfactory.js
     @ ./src/app/app.module.ngfactory.js
     @ ./src/main.ts
     @ multi ./src/main.ts
    ERROR in ./node_modules/rxjs/_esm5/observable/BoundCallbackObservable.js
    Module build failed: TypeError: Cannot read property 'type' of undefined
        at Object.getEffectiveTypeAnnotationNode (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:9341:17)
        at assignContextualParameterTypes (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:41652:25)
        at checkFunctionExpressionOrObjectLiteralMethod (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:41948:29)
        at checkExpressionWorker (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:42959:28)
        at checkExpression (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:42898:42)
        at checkExpressionCached (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:42779:38)
        at checkReturnStatement (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:45418:54)
        at checkSourceElement (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46763:28)
        at Object.forEach (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:1506:30)
        at checkBlock (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:44563:16)
        at checkSourceElement (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46742:28)
        at checkFunctionExpressionOrObjectLiteralMethodDeferred (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:41990:21)
        at checkDeferredNodes (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46828:25)
        at checkSourceFileWorker (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46863:17)
        at checkSourceFile (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:46842:13)
        at Object.forEach (/Users/german/github/angular-cms/node_modules/typescript/lib/typescript.js:1506:30)
     @ ./node_modules/rxjs/_esm5/observable/bindCallback.js 2:0-68
     @ ./node_modules/rxjs/_esm5/add/observable/bindCallback.js
     @ ./node_modules/rxjs/_esm5/Rx.js
     @ ./node_modules/angular2-datatable/lib/DataTable.js
     @ ./src/app/shared/tables/staff-table/staff-table.component.ngfactory.js
     @ ./src/app/components/staff/staff-list.component.ngfactory.js
     @ ./src/app/app.module.ngfactory.js
     @ ./src/main.ts
     @ multi ./src/main.ts```
    
    
  22. Bulan commented on Dec 14, 2017

    @Bulan

    Thx, suggestion by BartBurger (3rd post) worked like a charm.

    This should really make it into the upgrade guide, or an FAQ for upgrading

  23. sanjaynegi commented on Dec 15, 2017

    @sanjaynegi

    Upgrading typescript to latest solved the issue

  24. xiaosan666 commented on Apr 14, 2018

    @xiaosan666

    npm i [email protected] --save-dev

  25. angular-automatic-lock-bot commented on Sep 14, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  26. locked and limited conversation to collaborators on Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions