surveyjs / surveyjs_react_quickstart

SurveyJS + React Quickstart Template
http://surveyjs.io
141 stars 80 forks source link

Module not found: Can't resolve 'datatables.net/js/jquery.dataTables.js' in SurveyAnalyticsDatatables.js #32

Closed maciejbrasewicz closed 2 months ago

maciejbrasewicz commented 3 months ago

After following the setup instructions from the repository, I encounter a compilation error related to the datatables.net module. The error occurs when executing the npm run start command.

Expected Behavior:

The application should compile successfully and be accessible via http://localhost:3000/.

Actual Behavior:

The application fails to compile, displaying the following error:


Failed to compile.

Module not found: Error: Can't resolve 'datatables.net/js/jquery.dataTables.js' in 'check-in\surveyjs_react_quickstart\src\components'
ERROR in ./src/components/SurveyAnalyticsDatatables.js 9:0-48
Module not found: Error: Can't resolve 'datatables.net/js/jquery.dataTables.js' in 'check-in\surveyjs_react_quickstart\src\components'

webpack compiled with 1 error
pruchay commented 2 months ago

I have the same problem. In my case it was enough to update the file src/components/SurveyAnalyticsDatatables.js and change the line import "datatables.net/js/jquery.dataTables.js"; to import "https://cdn.datatables.net/2.1.4/js/dataTables.min.js";.

maciejbrasewicz commented 2 months ago

Thank you, I've already noticed. I'll make a PR when I have some time. The current version (2.1.4) no longer includes jquery.dataTables.js. Instead, we should use:

import "datatables.net/js/dataTables.js" You don't need to specify module paths for modern packages with valid entry points in their package.json. Therefore, this can be simplified to:

import "datatables.net"

There are additional issues with the setup, for instance:

"survey-core": "latest"

The boilerplate is outdated (last updated on August 10, 2022) and will likely break over time as dependencies update and introduce breaking changes. To resolve this, each dependency should be reviewed, and the versions considered "latest" at the time of the boilerplate's release should be identified. For related packages like survey-, version synchronization is common. Depending on the package, you might restrict the version to a major, minor, or patch level, likely 1.9 for survey- packages. Specifically, survey-analytics depends on datatables.net and caused a breaking change. A more stable configuration in package.json would be:

"survey-analytics": "1.9", "survey-core": "1.9",