Search code examples
javascriptreactjsdatatablenpm

How to import DataTables in npm?


The usual way of import "datatables.net-select"; doesn't seem to work.

I've looked on the website and it says to do:

var $       = require( 'jquery' );
var dt      = require( 'datatables.net' )( window, $ );

But I get a Cannot set property '$' of undefined

Am I missing something?


Solution

  • Figured it out.

    The only reason why I thought it wasn't working was because the css wasn't there. Make sure you also import the -dt stuff as well.

    I.e:

    import $ from 'jquery';
    
    import 'datatables.net';
    import 'datatables.net-dt/css/jquery.dataTables.css';