0

I have added a script reference to the RXjs library as well as including an import statement to the Rx root.

In my HTML:

<script src="libs/Rx.js"></script>
<script>
    System.config({
        map: {
            rxjs: '/libs/Rx' // added this map section
        },
        packages: {
            scripts: {
                defaultExtension: 'js'
            }
        }
    });
</script>

(I use Gulp to transfer the node_modules I need to a libs folder. This is something I needed to do to get Angular2 to work in Visual Studio 2015, as described in Starting Angular 2 in ASP.NET 5 with TypeScript using Visual Studio 2015.)

In my component:

import "rxjs/Rx";

I am getting these errors.

.../Rx/Observable 404 (Not Found)
.../Rx/Subject 404 (Not Found)
.../RX/operator/toPromise 404 (Not Found)
.../Rx/observable/PromiseObservable 404 (Not Found)
.../Rx/operators/map 404 (Not Found)

These were raised by system.src.js (line 4868). Why is Systemjs unable to find them? The Rx.js file has these defined.

Should I be including each of these explicitly in my component? Apart from "map", I don't use them explicitly in my project. These are probably being called from within map or another Rx method.

UPDATE

I updated my Gulp script to copy all the Rx libraries and folders instead of just the single bundle file. It fixed the issue.

2 Answers 2

1

You need to include the Rx.js or Rx.min.js file from the node_modules/rxjs/bundles folder not node_modules/rxjs folder.

Otherwise you need to configure Rxjs in the SystemJS configuration:

System.config({
  map: {
    'rxjs': 'node_modules/rxjs',
    (...)
  },
  packages: {
    (...)
  }
});
Sign up to request clarification or add additional context in comments.

3 Comments

I have a Gulp step that copies from node_modules to a lib folder. This is something that I had to do to get it to work in Visual Studio. Is there a difference in the Rx.js files between these different folders? As for the System.config suggestion, I read somewhere that it is no longer necessary for the latest version. I might be mistaken. I'll give it a try.
From tour error messages, the js extension is missing... I think that you should add an rxjs entry in the packages block of your systemjs configuration to define: defaultExtension: 'js'.
I already have that. I updated my post above to include System config.
0

Did you imported it the right way? Try this way.

import {Subject, Observable} from 'rxjs';

3 Comments

I don't use Subject or Observable within my component. Will I still need to do it anyway?
I would try to do it this way. import * from 'rxjs';
Visual Studio doesn't accept *. I'm getting build errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.