lundi 1 août 2016

I receive UncaughtReferenceError: Require is not defined. When importing for Angular 2 Testing

I am receiving this error in my Chrome console: Uncaught ReferenceError: require is not defined whenever I try to import and use a Service/Component. When I do not use a Service/Component the test works fine. I am using Jasmine and Karma.

import {HTTPService} from '../http.service';
import {Observable} from 'rxjs/Rx';
import {APPComponent} from './appcomponent.ts';

From posts and blogs that I have read changing the module to "system" in the tsconfig would solve it, but when I do the error changes from require to system is not defined. Below is my tsconfig file:

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  }
}

Is there something I am missing? Any help would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire