Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 5 production build issue #20095

Closed
aishanu opened this issue Nov 2, 2017 · 27 comments
Closed

Angular 5 production build issue #20095

aishanu opened this issue Nov 2, 2017 · 27 comments

Comments

@aishanu
Copy link

aishanu commented Nov 2, 2017

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

@aishanu
Copy link
Author

aishanu commented Nov 2, 2017

I am getting prodction build issue after upgrading to Angular v5

@HeroBart
Copy link

HeroBart commented Nov 2, 2017

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

@Toxicable
Copy link

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.

@rsaenen
Copy link

rsaenen commented Nov 8, 2017

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'

@Anoop-Goudar
Copy link

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

@angular/compiler-cli@5.0.0 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".

@lukeguzeng
Copy link

this solve my issue~~!!

@sondreb
Copy link

sondreb commented Nov 10, 2017

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()

@klochko7
Copy link

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)

@lincolnthree
Copy link
Contributor

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

@subatomicglue
Copy link

subatomicglue commented Nov 13, 2017

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.

@finalxcode
Copy link

finalxcode commented Nov 17, 2017

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

@bastienlemaitre
Copy link

Works with Typescript 2.4.2, i have replaced

import { Observable } from 'rxjs/Rx';

by

import { Observable } from 'rxjs/Observable';

@maiziheimei
Copy link

Yes, it solved by updating typescript's version

**For Exact version
npm install typescript@2.0.10 --save
**For latest release
npm install typescript@latest --save

@sburnicki
Copy link

I had this error when using

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

and needed to change it to

import {pipe} from "rxjs/util/pipe";

@iursevla
Copy link

I'm using only a single BehaviorSubject and the first method.
How to replace it like:
import { Observable } from 'rxjs/Rx';
to
import { Observable } from 'rxjs/Observable';

If i try to replace
import { BehaviorSubject } from 'rxjs/Rx';
to
import { BehaviorSubject } from 'rxjs/BehaviorSubject';

it gives an error in the .first method
See image

atereshkov pushed a commit to atereshkov/DiberWebClient that referenced this issue Nov 23, 2017
@bastienlemaitre
Copy link

bastienlemaitre commented Nov 24, 2017

You need to import operators.

@iursevla
Copy link

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

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

@iursevla
Copy link

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

import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import 'rxjs/add/operator/first';

@giscafer
Copy link

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'

@subatomicglue
Copy link

subatomicglue commented Nov 30, 2017

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)

@PixeliGer
Copy link

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```

@Bulan
Copy link

Bulan commented Dec 14, 2017

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

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

@sanjaynegi
Copy link

Upgrading typescript to latest solved the issue

@ghost
Copy link

ghost commented Dec 18, 2017

Changing
import { Observable } from 'rxjs/Rx';
to
import { Observable } from 'rxjs/Observable';
solved the issue.

@xiaosan666
Copy link

npm i typescript@2.6.1 --save-dev

@ghost
Copy link

ghost commented Dec 26, 2018

Works with Typescript 2.4.2, i have replaced

import { Observable } from 'rxjs/Rx';

by

import { Observable } from 'rxjs/Observable';

worked for me!

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests