NPM install and usage with Laravel 5.5 webpack mix

NPM install and usage with Laravel 5.5 webpack mix

sdroulerssdroulers Posts: 43Questions: 14Answers: 0

Hi,

I wanted to replace datatables/editor cdn install by npm and followed this steps which successfully installed everything (the code is from the generator)

npm install --save datatables.net-bs4
npm install --save datatables.net-editor-bs4
npm install --save datatables.net-buttons-bs4
npm install --save datatables.net-keytable-bs4
npm install --save datatables.net-responsive-bs4
npm install --save datatables.net-rowgroup-bs4

Then I did the following requires (still from the generator page):

require( 'datatables.net-bs4' )();
require( 'datatables.net-editor-bs4' )();
require( 'datatables.net-buttons-bs4' )();
require( 'datatables.net-buttons/js/buttons.html5.js' )();
require( 'datatables.net-buttons/js/buttons.print.js' )();
require( 'datatables.net-keytable-bs4' )();
require( 'datatables.net-responsive-bs4' )();
require( 'datatables.net-rowgroup-bs4' )();

and kept getting errors while compiling (webpack mix with Laravel 5.5). I had continuous errors of missing files with some packages.

For example when I did require('datatables.net-rowgroup-bs4');

Module not found: Error: Can't resolve 'datatables.net-rowgroup-bs4' in ...

From reading the npm extension page my understanding was that datatables.net-responsive-bs4 was for formatting only.

I'm in all confusion ! I'm surely missing some understanding on how to apply this my Laravel app. In anyone went through this, any suggestion would be greatly appreciated!

Sébastien

Answers

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Yes sorry - I've messed up a little here. For the styling only packages you would need to drop the styling part - e.g.:

    require( 'datatables.net-rowgroup' )();
    

    Since some of the extensions don't need styling Javascript, trying to include them directly will result in the error you are seeing. I'm going to include proxy JS in all of them for this reason with their next releases.

    Allan

  • sdroulerssdroulers Posts: 43Questions: 14Answers: 0

    Alright, I'll do this. Thanks

This discussion has been closed.