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

import bootstrap / jquery not working #445

Closed
chinookproject opened this issue Jun 22, 2016 · 4 comments
Closed

import bootstrap / jquery not working #445

chinookproject opened this issue Jun 22, 2016 · 4 comments

Comments

@chinookproject
Copy link

First of all, I appologize if this is the wrong place for this question. I wasn't sure where to post it. If so, then please let me know and I'll post it in the right repo.

The thing is, I created a new Aurelia project and installed bootstrap and jquery with jspm. I have a config.js that looks like this (only showing the parts that I think are important to show):

  map: {
    "aurelia-bootstrapper": "npm:aurelia-bootstrapper@1.0.0-beta.2.0.1",
    "aurelia-framework": "npm:aurelia-framework@1.0.0-beta.2.0.1",
    ...
    "jquery": "npm:jquery@3.0.0",
    ...
    "github:twbs/bootstrap@3.3.6": {
      "jquery": "npm:jquery@3.0.0"
    },
  }

But when I do:

import 'bootstrap'

I get an error the following error:

Error: (SystemJS) Error: Bootstrap's JavaScript requires jQuery(…)

But this seem to work fine in the skeleton navigation example?

I'm also getting the same error when I do:

import $ from 'jquery';
import 'bootstrap';

But, when I only import jquery it works fine:

import $ from 'jquery';

So my question is, whu isn't it working when I import bootstrap?

@AshleyGrant
Copy link
Collaborator

I helped you with this question on Stack Overflow, but I've since investigated a bit more. You can actually remove jQuery as a dependency for your application (so delete it from the dependencies in your package.json). After doing this, I recommend removing the map section of config.js, deleting the jspm_packages folder, and rerunning jspm install.

After doing this, you can actually access bootstrap's jQuery by doing this:

import $ from 'bootstrap';

If doing this doesn't work for you, then your best bet would be to file an issue with JSPM, as the issue you're experiencing is with JSPM and not Aurelia. https://github.com/jspm/jspm-cli

@chinookproject
Copy link
Author

I guess the problem is bootstrap. In their ``package.json` they have this:

  "jspm": {
    "main": "js/bootstrap",
    "shim": {
      "js/bootstrap": {
        "deps": "jquery",
        "exports": "$"
      }
    },

I guess that makes it download jQuery as well when doing a jspm install bootstrap. Problem is, that it's downloading jQuery 3.0.0, which isn't compatible with the current bootstrap 3.6.6 version.

Guess Bootsrap should update their package.json and add a version to the jquery dependency (if that's supported). I'll try to open a issue at bootstrap.

Thanks again for the help.

@AshleyGrant
Copy link
Collaborator

Well, I had an entire response typed out showing how this was working properly for me... and then I refreshed the app and it broke like you're showing.

But yeah, file an issue over there. But also ask in the jspm Gitter channel or file an issue w/jspm.

@EisenbergEffect
Copy link
Contributor

Appears to be a bug. We have updated the skeletons with a workaround.

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

3 participants