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: 65Questions: 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, $);
This question has an accepted answers - jump to answer
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
@allan I don't understand what I have done, but nothing works anymore if I take the one from the App.Js file
So it works, if I change the tables no longer work
Take one what?
In what way are you changing the tables?
Allan
@allan
I go here to the download page and take the npm code and run it, then I insert the code that is generated on the download page into the app.js file and the tables no longer load, I only see the header
app.js
package.json
What does the browser's console show? I presume there is an error message?
Allan
@allan I can't run the npm run build command and so I get tons of 404 not found errors
What do you mean you can't run it? As it in gets an error, or you can't type in your terminal, don't have a terminal, don't have npm or something else?
Allan
Looks like you've posted more information here. Let's carry on the conversation there rather than in two places.
Allan