Datatable Buttons : Cannot read properties of undefined (reading 'defaults')
Datatable Buttons : Cannot read properties of undefined (reading 'defaults')

Hello,
I'm using datatable with some additionnal plugins and Webpack to bundle all my assests.
I'm importing every needed plugins as follow :
const $ = require('jquery');
global.$ = global.jQuery = $;
import 'datatables.net-bs5';
import 'datatables.net-bs5/css/dataTables.bootstrap5.min.css';
import 'datatables.net-buttons-bs5';
import 'datatables.net-buttons/js/buttons.html5.js';
import 'datatables.net-buttons-bs5/css/buttons.bootstrap5.min.css';
import 'datatables.net-plugins/buttons/button.download.min.js';
import 'datatables.net-select-bs5';
import 'datatables.net-select-bs5/css/select.bootstrap5.min.css';
import 'datatables.net-datetime';
import 'datatables.net-datetime/dist/dataTables.dateTime.min.css';
import 'datatables.net-plugins/sorting/datetime-moment.js';
import 'datatables.net-searchbuilder-bs5';
import 'datatables.net-searchbuilder-bs5/css/searchBuilder.bootstrap5.min.css';
But when i try to run my application, i've got the following error :
Uncaught TypeError: Cannot read properties of undefined (reading 'defaults') buttons.bootstrap5.mjs:13
I found this https://datatables.net/forums/discussion/71921 where it point that i should import datatables first but i did it and still not working.
Also, i'm initializing my datatable as follow :
$('#dtID').DataTable({
....
});
What am i missing ?
Thanks for your help
Replies
I'm adding packages versions :
I've just tried creating an example and it appears to work okay: https://stackblitz.com/edit/hv7ntjs6?file=package.json,src%2Fmain.ts .
I've got it using Vite rather than Webpack there, simply because it was a lot easier to setup! Perhaps you can link to a minimal repo or Stackbltiz example showing the issue so I can help to debug it?
Allan
Thanks for your reply,
I edited your link (i'm on my way to make a more suitable exemple) as follow :
"datatables.net-bs5": "2.3.2" instead of "datatables.net-bs5": "^2.3.3",
"datatables.net-buttons-bs5": "3.2.3" instead of "datatables.net-buttons-bs5": "^3.2.4",
"datatables.net-select-bs5": "3.0.1"instead of datatables.net-select-bs5": "^3.1.0",
"jquery": "3.7.1" instead of "jquery": "^3.7.0"
I omitted fixed header, fixed column and plugin but i still reproduce the error :
Could it be version related ?
It is possible, although I can't immediately think of what would cause that.
If you update your versions to the latest, like in my example (minus jQuery), does it then work?
Allan
I update all my datatable.net-* packages and it's working !
Here's the used versions
Thanks for your help.
Awesome - thanks for letting me know.
Allan