Uncaught TypeError: Cannot read properties of undefined (reading 'Api')

Uncaught TypeError: Cannot read properties of undefined (reading 'Api')

surfwebbysurfwebby Posts: 11Questions: 2Answers: 0
edited September 2023 in Free community support

I installed datatables and extensions following the guide with npm.

Then I used this code to check whether everything worked:

import DataTable from 'datatables.net-dt';
import 'datatables.net-responsive-dt';

let table = new DataTable('#table-test', {
responsive: true
});

The error that appears to me once I have filled in the code is this:

Uncaught TypeError: Cannot read properties of undefined (reading 'Api')

If I remove the responsive extension everything works correctly.

Can anyone help me understand how to solve the problem?

Kind Regards
surfwebby

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,597Questions: 1Answers: 10,485 Site admin
    Answer ✓

    Hi,

    I've just tried it here and it appears to be working okay: https://codesandbox.io/s/musing-ramanujan-zn6w73?file=%2Fsrc%2Findex.html .

    Perhaps you can link to a test case showing the issue please?

    Allan

  • surfwebbysurfwebby Posts: 11Questions: 2Answers: 0

    Hi Allan.

    Thank you for your reply.

    Just now I tried deleting all the packages downloaded with npm and reinstalling them: I recompiled the script and everything works!

    I really have no idea why there was that error but fortunately I solved it.

    Sorry for posting without having done this test first.

    Kind Regards
    surfwebby

  • allanallan Posts: 63,597Questions: 1Answers: 10,485 Site admin

    Maybe an old version. Either way, good to hear you've got it working now.

    Allan

Sign In or Register to comment.