Error: [vite]: Rollup failed to resolve import "datatables.net/js/jquery.dataTables"
Error: [vite]: Rollup failed to resolve import "datatables.net/js/jquery.dataTables"
cmplus
Posts: 60Questions: 13Answers: 0
in DataTables
[vite]: Rollup failed to resolve import "datatables.net/js/jquery.dataTables" :
good morning, I use laravel 10 with datatables, my app.js is this, everything was working now but when I execute the npm run build command I receive this error message and the tables present in laravel disappear, what should I do to solve it?
app.js
import * as bootstrap from 'bootstrap';
window.bootstrap = bootstrap;
import 'laravel-datatables-vite';
import jQuery from 'jquery';
window.$ = jQuery;
import moment from "moment";
window.moment = moment();
import Editor from '@datatables.net/editor-dt';
import 'datatables.net-editor-bs5/js/editor.bootstrap5';
import 'datatables.net-bs5/js/dataTables.bootstrap5';
import 'datatables.net-select-bs5/js/select.bootstrap5';
import 'datatables.net-searchpanes/js/dataTables.searchPanes';
import 'datatables.net-searchpanes-bs5/js/searchPanes.bootstrap5';
import 'datatables.net-responsive-bs5/js/responsive.bootstrap5';
import 'datatables.net-buttons-bs5/js/buttons.bootstrap5';
import 'jquery/dist/jquery';
import 'datatables.net/js/jquery.dataTables';
import 'datatables.net-select/js/dataTables.select';
import 'datatables.net-rowgroup-bs5/js/rowGroup.bootstrap5.js';
import 'bootstrap/dist/js/bootstrap.bundle';
Editor(window, $);
Answers
doesn't exist. Not as of v2 anyway - it was updated to be just
dataTables.js
. Why are you importing the file names rather than just using the module and allowing it to auto resolve?Allan
@allan thanks for the reply, when I delete that line from the app.js file the table disappears, I have no idea how that line ended up there, and I don't understand why if I delete it the tables stop working
Without being able to see it, I don't know, but you could try changing it to
datatables.net/js/dataTables
(assuming you have v2 of DataTables installed, which I guess you do based on the error). You might want to check that all your DataTables dependencies are up to date to the latest versions.Allan