Angular 5. Error: ./node_modules/rxjs/observable/BoundNodeCallbackObservable.js


#1

Hi all ! Could anyone suggest please … how properly in Angular 5 use RXJS operators ? I can not build my app.

I receive the error when building with --prod flag (ionic).

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)
import { timeout } from 'rxjs/operator/timeout';
import { map } from 'rxjs/operator/map';
  this.http.post(this.login.rootUrl + 'logs.php', send).timeout(30000
  ).map(
  res=>res.json()
  ).subscribe(ans=> {
  loading.dismissAll();
   resolve(ans);
   },

Should I using .pipe() ? When I am trying

this.http.post(this.actions.deactivate, data).pipe(timeout(30000)).subscribe(serverData => { … my development environment highlights an error near pipe.

    @ionic/cli-utils  : 1.18.0
    ionic (Ionic CLI) : 3.18.0

global packages:

    cordova (Cordova CLI) : 7.1.0

local packages:

    @ionic/app-scripts : 3.1.0
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 25.2.5
    Node              : v6.9.0
    npm               : 3.10.8
    OS                : Windows 7

Environment Variables:

    ANDROID_HOME : C:\Users\anton\AppData\Local\Android\sdk

Misc:

    backend : pro

#2

Hi @anton_klochko

I had same issue…
The problem was I was using

import ‘rxjs/add/observable/bindCallback’;

I don’t know why it’s fail, but I commented that code line and it works.

Regards


#3

jbgomez21, good day ! And how you now import bindCallback ? You using this operator in your code ?


#4

I’m not using import bindCallback, but I had the code line import ‘rxjs/add/observable/bindCallback’ in my source


#5

I am getting the same error, no idea how to resolve so far

ionic cordova run android --prod

: ./node_modules/rxjs/observable/BoundCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
  @ionic/cli-utils  : 1.18.0
    ionic (Ionic CLI) : 3.18.0

global packages:

    cordova (Cordova CLI) : not installed

local packages:

    @ionic/app-scripts : 3.1.1
    Cordova Platforms  : android 6.2.3
    Ionic Framework    : ionic-angular 3.9.2

System:

    Android SDK Tools : 25.2.5
    Node              : v6.9.2
    npm               : 5.3.0
    OS                : Windows 7

#6

npm install -g typescript@2.6.1 and remove import 'rxjs'; help a little …


#7

I just seem to have solved this for me by:

  • updating to typescript 2.6.1
  • removing all import 'rxjs'; statements from various files (guess they were outdated anyway)
  • adding a single import 'rxjs/Rx'; statement in the main.ts

also I always use imports like import {Observable} from 'rxjs/Observable'; instead of import {Observable} from 'rxjs'; some peoeple seem to have had problems with those after upgrading

see also https://github.com/angular/angular/issues/20095


#8

I updated typescript to 2.6.1 and Observable and all operators (of, concat, timeout, retry, do, empty) i import from rxjs package: import { Observable } from 'rxjs';

Now i can build the app, thanks guys!


#9

Please read de documentation since HttpClient section because some things have changed and you need to update them. Read this article:
https://alligator.io/angular/angular-5/ and maybe you can use https://angular-update-guide.firebaseapp.com/


#10

i had same issue. I have changed import { Observable } from ‘rxjs/Rx’; to import { Observable } from ‘rxjs/Observable’;. It got resolved. I may be late but Hope it will help