Do exists a datatables.net-editor npm package for the Editor of the 1.9.6 version?

Do exists a datatables.net-editor npm package for the Editor of the 1.9.6 version?

eugenokeugenok Posts: 13Questions: 2Answers: 0

After installing:
npm install --save datatables.net-editor

I have got "datatables.net-editor": "^2.1.0", (but probably I need something for v1.9)

and after adding the license with the script: node_modules/datatables.net-editor/install.js ...
I still see a message in the console output:
"If you are seeing this message, it is because Editor has been installed using npm install datatables.net-editor, but the licensed or trial files have not been installed in place of the holding files."

Is it even possible to use Editor v1.9.6 with any npm package?

Regards,
Eugene.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,635Questions: 1Answers: 10,092 Site admin

    Hi Eugene,

    The datatables.net-editor package from npm is basically just a holding package. You need to run the install script to copy the files form a zip file to the node_modules directory. So as long as you point the install script to a 1.9.6 zip file, it should install correctly.

    The one thing that might be causing a problem with this is the newer .mjs files. They didn't exist in the 1.x releases (only added in 2.1.x) so the installer wouldn't be able to replace them. If you are then using a bundler such as Vite which automatically uses module files if it can, that would cause what you are seeing.

    You could try deleting the .mjs files in node_modules/datatables.net-editor/js to see if that is indeed what is causing the issue.

    Allan

  • eugenokeugenok Posts: 13Questions: 2Answers: 0

    Thanks Allan, yes, looks like all files are in the place. Installer did its job. Just can't start Editor to check if it works, but that should be another question...

    Will be good to see some example of Vue 3 (typescript) + Editor.
    I have read this: https://datatables.net/blog/2022-06-22-vue, but it is only Datatables about.

    Regards,
    Eugene

  • allanallan Posts: 61,635Questions: 1Answers: 10,092 Site admin

    Did you try removing the .mjs files? Are you still getting the license not found error?

    Will be good to see some example of Vue 3 (typescript) + Editor.

    Agreed. I do plan to put such an example together, although it is basically the same as the other extensions, the only difference being that import Editor from 'datatables.net-editor'; imports the Editor class.

    Allan

  • eugenokeugenok Posts: 13Questions: 2Answers: 0

    Hi Allan,
    I still was getting messages about the license, because of the node_modules/.vite/deps cache, and after deleting it got other message, now on the start of app:
    npm run dev:
    [vite] Internal server error: Failed to resolve entry for package "datatables.net-editor". The package may have incorrect main/module/exports specified in its package.json.

    But before it was running without any errors... I think it is connected with some mine misconfigurations...

    About the Editor, yes, I tried to import it with
    import Editor from 'datatables.net-editor';

    but the next question how to make it work, I don't see any buttons (like 'copy', 'create', ...), which I tried to

    <template>
    <DataTable id="table" :ref="(el) => {refTable = el}" class="display nowrap" :columns="columns"
    :data="data" :options="{ dom: 'Bfrtipl', select: { style: 'single' } }"
    :buttons="[ 'copy', { extend: 'create', editor: editor }]" />

    The table is working correctly but I can't manage how the DataTable instance should be linked with the Editor instance (and how to create last one in the right way, I'm trying to do that in a Component/data hook). I'm trying to use TypeScript and without jQuery.

    Editor as I understand in general is linked with Datatables over its "table:" property, and Datatables's buttons linked with Editor by the "editor" property.

    Is it possible to do that in the typescript style?

    Eugene

  • allanallan Posts: 61,635Questions: 1Answers: 10,092 Site admin
    Answer ✓

    Try editing the node_modules/datatables.net-editor/package.json file and remove the "module": ... line. Vite is probably seeing that and attempting to use the .mjs file, which is now no longer there.

    I wonder if it might actually be easier to install datatables.net-editor@2.0.5 which was prior to the inclusion of the ES modules.

    That said, if you are using Editor with Typescript, you are likely going to want to upgrade to 2.1.x. I've focused a lot more effort on getting the Typescript stuff working recently and Editor 2.x is compiled with Typescript. 1.x wasn't fully tested for it.

    Allan

  • eugenokeugenok Posts: 13Questions: 2Answers: 0

    Yes, that's time to upgrade. Will try.

    Eugene.

Sign In or Register to comment.