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

404 when using import #155

Open
cAhmad opened this issue May 18, 2016 · 8 comments
Open

404 when using import #155

cAhmad opened this issue May 18, 2016 · 8 comments

Comments

@cAhmad
Copy link

cAhmad commented May 18, 2016

Hi, I'm trying to use karma-jspm, after your last release I do not have the too many open file so I can go on.

Now I'm facing a new issue, I read the #91, but that's not my case, my jspm.config.js has an empty baseURL

When I run my es5 tests it fails with:

ReferenceError: module is not defined

Which is fine since I didn't import it (my app is with AngularJS)

So when I try to:

import angular from 'angular';
import 'angular-mocks';

I get this error:

18 05 2016 11:46:32.089:WARN [web-server]: 404: /base/jspm_packages/npm/babel-core@5.8.34.js
Chrome 50.0.2661 (Linux 0.0.0) ERROR
  Error: XHR error (404 Not Found) loading /jspm_packages/npm/babel-core@5.8.34.js
        Error loading /jspm_packages/npm/babel-core@5.8.34.js
        Error loading /test/javascript/unit/i18n.spec.js

Does anyone have any tips or idea, what I'm missing here?

@Ixonal
Copy link

Ixonal commented Jun 7, 2016

I'm currently having what looks to be the same issue, but with TypeScript.

@sergei-maertens
Copy link

This looks like something you could fix with a proxy configuration in karma like this:

proxies: {
    '/jspm_packages/': '/base/jspm_packages/'
},

Provided that jspm_packages lives in the root of your project. Can you show your existing proxies configuration and the directory structure of your project, + the karma.conf.js file contents?

@Ixonal
Copy link

Ixonal commented Jun 7, 2016

I've been through many permutations for the config file, including using proxies, but keep getting the same issue.

here's my config file

module.exports = function(config) {
  config.set({
    //logLevel: config.LOG_DEBUG,

    frameworks: ["jspm", "jasmine"],
    reporters: ["progress"],
    browsers: ["PhantomJS"],
    // files: [
    //   { pattern: "test/*.spec.ts", included: true },
    //   { pattern: "dist/**/*.js", included: false, served: true }
    // ],

    proxies: {
      "jspm_packages/": "base/jspm_packages/",
      "test/": "base/test/",
      "src/": "base/src/"
    },

    jspm: {
      config: "./config.js",

      loadFiles: [
        "test/**/*.ts"
      ],
      serveFiles: [
        "jspm_packages/**/*.js",
        "src/**/*.ts"
      ],

      paths: {
        "aurelia-service-generator/*": "dist/*"
      }
    }//,

    // preprocessors: {
    //   "test/**/*.ts": ["typescript"]
    // },

    // typescriptPreprocessor: {
    //   options: {
    //     noResolve: true,
    //     module: 'amd'
    //   },
    //   transformPath: function(path) {
    //     return path.replace(/\.ts$/, '.js');
    //   }
    // }
  });
}

And here's my Systemjs config file

System.config({
  //defaultJSExtensions: true,

  transpiler: "typescript",
  paths: {
    "github:*": "jspm_packages/github/*",
    "npm:*": "jspm_packages/npm/*"
  },

  map: {
    "typescript": "npm:typescript@1.8.10",
    "github:jspm/nodelibs-os@0.1.0": {
      "os-browserify": "npm:os-browserify@0.1.2"
    },
    "npm:os-browserify@0.1.2": {
      "os": "github:jspm/nodelibs-os@0.1.0"
    },
    "npm:typescript@1.8.10": {
      "os": "github:jspm/nodelibs-os@0.1.0"
    }
  }
});

And just in case, here's the spec I'm trying to load

import { TypeScriptServiceBuilder } from "../src/construction/typeScript/TypeScriptServiceBuilder";

describe("TypeScriptServiceBuilder", function() {

  it("exists", function() {
    expect(TypeScriptServiceBuilder).toBeTruthy();
  });

});

Aaaannnnndddddd here's a (slightly abridged, emptied node_modules) copy of my directory structure

+---build
+---dist
|   +---construction
|   |   +---es2015
|   |   +---es5
|   |   +---interfaces
|   |   \---typeScript
|   +---dts
|   |   +---construction
|   |   |   +---es2015
|   |   |   +---es5
|   |   |   +---interfaces
|   |   |   \---typeScript
|   |   +---gulp
|   |   +---interpretation
|   |   |   \---swagger
|   |   |       \---interfaces
|   |   +---Swagger
|   |   |   \---interfaces
|   |   \---util
|   +---gulp
|   +---interpretation
|   |   \---swagger
|   |       \---interfaces
|   +---Swagger
|   |   \---interfaces
|   \---util
+---jspm_packages
|   +---github
|   |   \---jspm
|   |       \---nodelibs-os@0.1.0
|   \---npm
|       +---os-browserify@0.1.2
|       \---typescript@1.8.10
|           +---bin
|           \---lib
+---node_modules
+---src
|   +---construction
|   |   +---es2015
|   |   +---es5
|   |   +---interfaces
|   |   \---typeScript
|   +---gulp
|   +---interpretation
|   |   \---swagger
|   |       \---interfaces
|   \---util
+---test
|   \---resources
\---typings
    +---form-data
    +---glob
    +---glob-stream
    +---jasmine
    +---minimatch
    +---node
    +---request
    +---vinyl
    \---vinyl-fs

@Ixonal
Copy link

Ixonal commented Jun 11, 2016

@sergei-maertens just in case, ping.

@sergei-maertens
Copy link

I have no quick ideas, sorry :(
On Jun 11, 2016 06:05, "Benjamin McGregor" notifications@github.com wrote:

@sergei-maertens https://github.com/sergei-maertens just in case, ping.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#155 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AFQ01hT8u8utXB-Mwpz8UV8UQWPIQyn2ks5qKjPzgaJpZM4IhH7T
.

@FredLoney
Copy link

Perhaps you need to install plugin-babel:

jspm install npm:systemjs-plugin-babel

@Ixonal
Copy link

Ixonal commented Jun 14, 2016

@FredLoney I'm using TypeScript instead of Babel, and it's set up to use it in the system config and it exists in the jspm_packages folder

@FredLoney
Copy link

This might be karma-jspm/jspm interaction weirdness. I use typescript as well, but my karma-jspm fails on a missing traceur library. When I add it, the test runs. jspm checks the transpiler name against a list of known transpilers and loads libraries accordingly. traceur is the first in the list and babel is the last--and default--in the list. In my situation, this is the only place in the entire app that could potentially request a traceur library. It could be that jspm is not detecting your transpiler name correctly and falls through to babel. If so, the first library jspm would request is babel-core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants