Reputation: 6019
After installing Meteor via Chocolatey on windows 10, and meteor add twbs:bootstrap
This Meteor app gives a barowser error
Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3
So which version am I running now?
meteor list
did not produce any jquery related lines.
./meteor/versions
file has a line saying "[email protected]"
But didn't meteor create
already install a jQuery as per the web site? "This package is automatically included in every new Meteor app by meteor create."
DO I need to run meteor add jquery
? but I remember doing that already at least once. and "jquery": "^3.5.1"
is under dependencies in packages.json and package-lock.json
The command: meteor show jquery
shows package: [email protected]
Please help untangle this. Thanks
Solved:
meteor remove twbs:bootstrap
npm install bootstrap
Added "popper.js":"^1.16.0"
to dependencies in package.json
Upvotes: 0
Views: 920
Reputation: 8413
There is a difference between the Meteor package version [email protected]
and the npm version `"jquery": "^3.5.1".
The Meteor package [email protected]
allows to override deprecated jQuery versions (for example delivered as direct dependency of an old Meteor package) with the jQuery version, installed via npm.
./meteor/versions
file has a line saying"[email protected]"
Note, that just adding [email protected]
sometimes fails (when packages require direct dependencies). Then you have to change in your .meteor/packages
the entry [email protected]
to [email protected]!
However, this may still cause the mentioned error, because your jQuery will be a version > 3 (because your project will then use the npm jQuery 3.5.1).
What are your options then to resolve the error:
jquery
> 1 and < 3option a
The first option would basically require you to run meteor npm install --save [email protected]
to get the latest jQuery < 3.
This could be a fast solution, if your app will be used internally (for example in a corporate intranet or smth.) but would be a big problem if out in the wild. There are plenty of vulnerabilities that have been detected since 3.5.1
and you should think about, whether this will be an issue or not.
option b
The better way is to also use the latest bootstrap an jQuery from the beginning and use their npm packages. It is a bit more of work than just adding twbs:bootstrap
but it gives you the flexibility and maintainability that you need:
$ meteor remove twbs:botstrap
$ meteor npm install --save jquery@latest bootstrap popper.js
Open .meteor/packages
in your editor of choice and change:
[email protected]
to [email protected]!
In your startup routine, for example in client/main.js
you do the following:
import 'bootstrap'
import 'bootstrap/dist/css/bootstrap.css' // default theme
import popper from 'popper.js'
global.Popper = global.Popper || popper
If you want to apply your own theme, your may also install the scss toolchain:
$ meteor remove standard-minifier-css
$ meteor add fourseven:scss seba:minifiers-autoprefixer
and then import your custom theme instead of the standard css:
import 'bootstrap'
import popper from 'popper.js'
import './theme.scss'
global.Popper = global.Popper || popper
to apply your own theme, you need to have theme.scss
to follow the structure below:
/* import the necessary Bootstrap files */
@import "{}/node_modules/bootstrap/scss/functions";
@import "{}/node_modules/bootstrap/scss/variables";
@import "{}/node_modules/bootstrap/scss/mixins/buttons";
/* these are just examples, if your theme overrides more you need to import the respective files */
/* -------begin customization-------- */
/* here your custom theme variables, colors etc. */
/* ------- end customization -------- */
/* finally, import Bootstrap to set the changes! */
@import "{}/node_modules/bootstrap/scss/bootstrap.scss";
I know this might be too much of an answer but in the long run I highly suggest you to omit the deprecated BS3 and go for a more flexible strategy, as shown in option b here.
Upvotes: 3