ReactiveX / rxjs

A reactive programming library for JavaScript
https://rxjs.dev
Apache License 2.0
30.73k stars 3k forks source link

Error looking for rxjs/operators.js #2971

Closed bmkleine closed 6 years ago

bmkleine commented 7 years ago

RxJS version: 5.5.0

Additional information: It looks like there is still one place using the old operators file (src/observable/dom/AjaxObservable.ts) line 7: import { map } from '../../operators';

nagarajpatil commented 7 years ago

Is this issue fixed?

gildebrand commented 7 years ago

We ran into this issue as well, and pinned RxJS to version 5.4.3. This made it work for us again.

Tovrik commented 7 years ago

Did the same as @gildebrand but hoping that is just a temporary change and they fix it in 5.5.1 real fast 😬

apeman86 commented 7 years ago

We had to do the same as @gildebrand.

kwonoj commented 7 years ago

anyone mind sharing small repo to test out this failure? I'm trying to look into this now.

jasonaden commented 7 years ago

I would be willing to bet this is using SystemJS.

Internally we shouldn't be referring to rxjs/operators as it will work in development, but will fail with SystemJS.

gildebrand commented 7 years ago

@jasonaden that's correct that this occurs with SystemJS!

kwonoj commented 7 years ago

I have pushed fix, there'll be patch release once it's available.

nagarajpatil commented 7 years ago

Thanks version 5.4.3 worked for me.

From: Anton Gildebrand [mailto:notifications@github.com] Sent: Wednesday, October 18, 2017 2:47 PM To: ReactiveX/rxjs rxjs@noreply.github.com Cc: nagarajpatil nagaraj.patil@hotmail.com; Comment comment@noreply.github.com Subject: Re: [ReactiveX/rxjs] Error looking for rxjs/operators.js (#2971)

We ran into this issue as well, and pinned RxJS to version 5.4.3. This made it work for us again.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/ReactiveX/rxjs/issues/2971#issuecomment-337737871, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AVopn1BQk0hRRMhSxfs-xWrnK7h_kICZks5stnHngaJpZM4P-Ha-.

zrsio4 commented 7 years ago

I've also reverted back to 5.4.3 for now. I had a similar but different error when I removed rxjs from SystemJS config and added ".../node_modules/rxjs/bundles/Rx.js" script tag to the page header.

alan-agius4 commented 7 years ago

Having the same problem as well.

buu700 commented 7 years ago

I'm using webpack (Angular CLI), and all the operator functions are undefined at run-time for me with 5.5.0. Specifically, I'm getting an error when .first() is called on a BehaviorSubject.

Is this the same bug described here, or should I report it separately?

jasonaden commented 7 years ago

@buu700 I think this is a separate issue. If you could file an issue with a reproduction, that would be great.

buu700 commented 7 years ago

Got it, thanks! Actually, upon further investigation, I'm not sure whether this is an rxjs or Angular bug, so I'll report the details in a ticket there and CC you.

Edit: Actually this is probably just a package version mismatch.

shaycraft commented 7 years ago

I had this problem too (fixed by reverting the version) and I am using SystemJS. Is only WebPack going to be supported in the future?

jasonaden commented 7 years ago

@shaycraft Nope. Just waiting for a 5.5.1 release. If you were on master SystemJS would be working right now.

mlc-mlapis commented 7 years ago

This the file operators.js (zipped) that is necessary to temporarily add to node_modules/rxjs directory for RxJS 5.5.0 to enable it for using with SystemJS:

operators.zip

kylecordes commented 7 years ago

I maintain an automatic parallel package of RxJS, which produces a SystemJS bundle: https://www.npmjs.com/package/rxjs-system-bundle

... and of course I hit the same problem. I worked around it:

https://github.com/OasisDigital/rxjs-system-bundle/commit/b0f714aa307cb89f14bc6097783c6453674e81d5#diff-0b83f9dedf40d7356e5ca147a077acb4R9

with a (hopefully very temporary) hack consisting of a single sed command:

sed -e "s/'\./'.\/operators/" <node_modules/rxjs/operators/index.js >node_modules/rxjs/operators.js

I don't recommend this, I just did it to keep producing a working bundle. Hopefully the need will evaporate with the upcoming 5.5.1.

pe8ter commented 7 years ago

@kylecordes I'm still seeing this issue with my SystemJS bundle on 5.5.1.

EDIT: But I suspect that this is a problem with my systemjs-builder config and not rxjs.

babeal commented 7 years ago

@pe8ter no i am seeing the same thing. They are requiring "operators" which is a folder which isn't allowed. Only webpack (or other bundler) allows import of folder where it assumes you mean the index inside of the folder. There is no way for system.js in the client to do this. This needs to be fixed as it is a breaking change.

kylecordes commented 7 years ago

@babeal What you're saying is true of the code as it is arrives from RxJS, but it is possible to work around it, and I have done so with an awful hack that I mentioned a few messages up. My hack creates the missing operators.ts file. It is ugly but it does work fine. When I get a chance I will post a Plunkr demonstrating it.

mlc-mlapis commented 7 years ago

@jasonaden ... did we understand wrongly that version 5.5.1 eliminates the problem with missing operators.js file (https://github.com/ReactiveX/rxjs/issues/2971#issuecomment-338316966)?

babeal commented 7 years ago

@kylecordes yea thanks. I hear you it's easy to fix but I don't want to have to do that for the 15 projects I maintain so I will lock to 5.4.x until this is fixed.

kylecordes commented 6 years ago

@pe8ter @babeal @mlc-mlapis Here are the changes in RxJS between 5.5.0 and 5.5.1; I don't think any of these are relevant to our SystemJS operators.ts problem here unfortunately. So I think the @kwonoj fix must have been about a different 5.5.0 glitch.

https://github.com/ReactiveX/rxjs/compare/9538a2024973d9a5c3cbeb26503cc8090dd6b806...0650c52c937cc5153a3d1cc23daf1a689dd921f4

Here is a plunkr which shows my SystemJS redistribution of RxJS in action (look at config.js). Take a look at app.ts to see the operator import.

https://plnkr.co/edit/4Y6KAJ28Wwua8RSVaV8A?p=preview

schwede commented 6 years ago

It looks to me like the issue was introduced here: https://github.com/ReactiveX/rxjs/commit/ba2f58686128c910a3391b0ace697b34d8542b78#diff-5fe03a9b5bb68d1a34618cf458d64e1c

Is anyone working on a pull request for this?

mlc-mlapis commented 6 years ago

@kylecordes ... shouldn't be "rxjs/operators/*", added also?

bundles: {
    "npm:rxjs-system-bundle@5.5.0/Rx.system.js": [
      "rxjs",
      "rxjs/*",
      "rxjs/operator/*",
      "rxjs/operators/*",
      "rxjs/observable/*",
      "rxjs/scheduler/*",
      "rxjs/symbol/*",
      "rxjs/add/operator/*",
      "rxjs/add/observable/*",
      "rxjs/util/*"
    ]
}
mlc-mlapis commented 6 years ago

@kylecordes ... you should also apply zone-patch-rxjs.js from zone.js because the problem with RxJS scheduler & zone is still not solved in RxJS.

kylecordes commented 6 years ago

@mlc-mlapis I have updated the plunker to make available (although the example doesn't import anything that way), and to apply the zone-patch-rxjs patch (although the example run OK without it already). Hopefully having this plunker sitting here linked will help out any passerby who comes along and needs the new lettable operator syntax to work via SystemJS, between now and when a more official fix can be made.

(By the way, this is my favorite kind of open-source contribution... a temporary thing to help fix an interim problem, to be later made obsolete by an upstream project so I won't feel guilt to maintain it forever :-) )

vmagalhaes commented 6 years ago

So... SystemJS projects doesn't work in this moment? Is there a date to work? I need a solution as soon as possible.

mlc-mlapis commented 6 years ago

@ViictorG1 ... RxJS doesn't work even as 5.5.2 ... still the same problem .... but you can use advises above ... it works without any problems using them when waiting for a final solution.

vmagalhaes commented 6 years ago

@mlc-mlapis at this moment I'm insert operators.js inside dist/node_modules/rxjs but it's so wrong... What you advise to me do?

mlc-mlapis commented 6 years ago

@ViictorG1 ... as a permanent solution of course but still working ... I suppose that RxJS 5.5.3 will be there very soon and it'll be the right one for the problem.

I need a solution as soon as possible.

vmagalhaes commented 6 years ago

@mlc-mlapis Ok, thanks, let's wait for permanent solution as soon as possible.

sarunint commented 6 years ago

I think inserting this line into SystemJS config should fix this problem:

'rxjs/operators': 'npm:rxjs@5.5.2/operators/index.js',

This is intended to be temporary to wait for the actual fix.

acrisci commented 6 years ago

workaround:

echo 'require('./operators/index.js');' > node_modules/rxjs/operators.js
pitAlex commented 6 years ago

I did this to make it work:

packages : {
    "rxjs/operators" : {
         "main": "index.js",
         "defaultExtension": "js"
    }
}
keithdechant commented 6 years ago

@pitAlex That worked great for me on my Angular 5 app. It's nice to have a workaround that doesn't require editing anything in node_modules.

You're missing a colon after "rxjs/operators", BTW.

sarunint commented 6 years ago

This issue is fixed in 5.5.3. All workarounds above can be ignored.

bevlison commented 6 years ago

I had the error : "looking for rxjs/operators.js", when loading an angular TS file : "....service.js" , line 3 containing : "import { catchError, map, tap } from 'rxjs/operators';" line 1 containing : "import { Observable } from 'rxjs/Observable';". That line gives no error! (so rxjs is available)

I don't know how relevant this is, but the solution was not changing version (of rxjs), nor editing the file named "systemjs.config.js", (adding a seperated referal to rxjs/operators, as a post above suggested to do). That systemjs file contains : "'rxjs': 'npm:rxjs',", which is explaining the availability of eg. rxjs/Observable in angular TS

SOLUTION for me was : changing line 3 in service file to : "import { catchError, map, tap } from 'rxjs/operators/index';"

EXPLAINED : When checking "./node_modules/rxjs" you won't find a file "operators.js", but you'll find a folder "operators". you could refer to the needed operators, or just all available (choosing for index.js)

Hopefully this solves and explains for others following same tutorials as I'm doing.

ChandraTerli commented 6 years ago

I am still having the same issue in Angular 6.0.0? does the issue still exists in latest version?

mlc-mlapis commented 6 years ago

@ChandraTerli ... ??? it was the issue with RxJS itself and not with Angular.

ChandraTerli commented 6 years ago

Thank you! for the response, I tried your suggestion but got 403 error saying access to is forbidden.

Sent from my iPhone

On May 7, 2018, at 5:17 PM, Miloš Lapiš notifications@github.com wrote:

@ChandraTerli ... ??? it was the issue with RxJS itself and not with Angular.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ChandraTerli commented 6 years ago

this is what I is in my Package.Json... "rxjs": "6.1.0" and in SystemJs.Config.., 'rxjs/operators': { 'main': 'index.js', 'defaultExtension': 'js' }

ChandraTerli commented 6 years ago

and I get this error.. http://localhost:41211/node_modules/rxjs/ 403 (Forbidden)

mlc-mlapis commented 6 years ago

@ChandraTerli ... but the error is related to rxjs and not to rxjs/operators:

http://localhost:41211/node_modules/rxjs/ 403 (Forbidden)

Are you importing what when the error appears?

ChandraTerli commented 6 years ago

initial error was rxjs/operators then when I tried to fix it using what I mentioned above it started giving me this error, no not when importing. I am just trying to build a angular6 project and on initial run I see this error(s).

ChandraTerli commented 6 years ago

{ "name": "angular-quickstart", "version": "1.0.0", "description": "QuickStart package.json from the documentation, supplemented with testing support", "scripts": { "build": "tsc -p src/", "build:watch": "tsc -p src/ -w", "build:e2e": "tsc -p e2e/", "serve": "lite-server -c=bs-config.json", "serve:e2e": "lite-server -c=bs-config.e2e.json", "prestart": "npm run build", "start": "concurrently \"npm run build:watch\" \"npm run serve\"", "pree2e": "npm run build:e2e", "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first", "preprotractor": "webdriver-manager update", "protractor": "protractor protractor.config.js", "pretest": "npm run build", "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"", "pretest:once": "npm run build", "test:once": "karma start karma.conf.js --single-run", "lint": "tslint ./src/*/.ts -t verbose" }, "keywords": [], "author": "", "license": "MIT", "dependencies": { "@angular/animations": "^6.0.0", "@angular/common": "~6.0.0", "@angular/compiler": "~6.0.0", "@angular/core": "~6.0.0", "@angular/forms": "~6.0.0", "@angular/http": "~6.0.0", "@angular/platform-browser": "~6.0.0", "@angular/platform-browser-dynamic": "~6.0.0", "@angular/router": "~6.0.0", "angular-in-memory-web-api": "~0.6.0", "systemjs": "0.21.3", "core-js": "^2.5.6", "rxjs": "6.1.0", "zone.js": "0.8.26" }, "devDependencies": { "concurrently": "^3.2.0", "lite-server": "^2.2.2", "typescript": "~2.5.3", "canonical-path": "0.0.2", "tslint": "^3.15.1", "lodash": "^4.16.4", "jasmine-core": "~2.4.1", "karma": "^1.3.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~4.0.14", "rimraf": "^2.5.4", "@types/node": "^6.0.46", "@types/jasmine": "2.5.36" }, "repository": {} }

ChandraTerli commented 6 years ago

/**

mlc-mlapis commented 6 years ago

@ChandraTerli ... it looks that you use SystemJS in the project. Is it an older app? And you want to migrate to Angular 6 now? Then I recommend you to start with a fresh project and with Angular CLI and migrate you previous app step by step.

adal2404-Real commented 6 years ago

Hello!, taken the @pitAlex recommendations, I makes that change on system.config.js and add a similar rxjs config for the error http://localhost:41211/node_modules/rxjs/ 403 (Forbidden), tested with Angular 6.0.3 and rxjs 6.2.0, and it work!!

  packages: {
        app: {
            defaultExtension: 'js',
            meta: {
                './*.js': {
                    loader: 'systemjs-angular-loader.js'
                }
            }
        },
        rxjs: {
            main: 'index.js',
            defaultExtension: 'js'
        },
        "rxjs/operators": {
            main: 'index.js',
            defaultExtension: 'js'
        }
    }