Using Browserify Issue
Using Browserify Issue
aaesis
Posts: 2Questions: 1Answers: 0
Hi Im using browserify, and I download the dataTables through NPM Install. when I include the plugin to my project.
Sample Code: import DataTable from 'datatables.net'
the error is DataTable is not a function. How can I fix that issue? Does the datatables does not support import? Modular Javascript?
Also I would like to include the styling but cannot compile in sass if I used .css extension, is there any SASS file for dataTables styling?
This discussion has been closed.
Answers
It should be quite possible it use DataTables with Browserify. Have you
npm install datatables.net
? Or did you use some other package?DataTables' native CSS is SCSS (which should be compilable by SASS). The styling package is
datatables.net-dt
for DataTables' native styling.Allan
Hi Allan Thanks for answering my question.
What I have did is:
npm install datatables.net
npm install datatables.net-dt
screenshot save in my packages.json please see below.
my code below:
===================================================
import DataTable from 'datatables.net'
class Datatables
{
createTable(elem, opts) {
$(elem).DataTable(opts)
}
}
export default Datatables;
error:
DataTable is not a function.
So I imported datatables.net from the node_modules.
SASS is now ok.
What are you using the transpile the code? I suspect this is going to be related to the CommonJS loader which needs to be executed as a function (see the npm install instructions).
Exactly how you do that with ES2015 module syntax I'm not entirely sure! I'll need to look into that.
Allan