Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't import "bootstrap-select" in app.scss in Laravel

I'm doing following:

npm install bootstrap-select

npm run dev

in app.scss

// Bootstrap Select

@import "node_modules/bootstrap-select/sass/bootstrap-select.scss";

In console it says:

jQuery.Deferred exception: $(...).selectpicker is not a function
TypeError: $(...).selectpicker is not a function

I can see it installed bootstrap-select, how do I import it correctly?

like image 619
user2060000 Avatar asked Sep 12 '25 01:09

user2060000


2 Answers

In your /resources/assets/sass/app.scss import bootstrap-select:

@import "../../../node_modules/bootstrap-select/sass/bootstrap-select.scss";

You also need to import bootstrap-select.js to resources/assets/js/app.js make it work:

require('../../../node_modules/bootstrap-select/dist/js/bootstrap-select');

Its possible to add Bootstrap-Select without the complete path:

require('bootstrap-select');
require('bootstrap-select/js/i18n/defaults-de_DE');
@import '~bootstrap-select/sass/bootstrap-select.scss';
like image 22
dipser Avatar answered Sep 14 '25 14:09

dipser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!