import bootstrap / jquery not working
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:[email protected]",
"aurelia-framework": "npm:[email protected]",
...
"jquery": "npm:[email protected]",
...
"github:twbs/[email protected]": {
"jquery": "npm:[email protected]"
},
}
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?
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
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.
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.
Appears to be a bug. We have updated the skeletons with a workaround.