capacitor-community/sqlite

Problem with the version of node-fetch package in electron app

antoniovlx opened this issue · 1 comments

In section Electron Quirks is required to install node-fetch because the plugin uses it in an electron app.

I've installed the last version (3.3.0) and I get an error when I run the app:

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\anton\git\ionic-angular-template\electron\node_modules\node-fetch\src\index.js from C:\Users\anton\git\ionic-angular-template\electron\node_modules\@capacitor-community\sqlite\electron\dist\plugin.js not supported.

The node-fetch error "[ERR_REQUIRE_ESM]: require() not supported" occurs because the node-fetch package has been converted to be an ESM-only package in version 3, which means that the package can't be imported with require().

Solutions: use a dynamic import to import the node-fetch package in the library or downgrade the version of the package to 2.6.7, which is the last version that is built with CommonJS.

I think it's necessary to warn this scenario in the readme and indicate that the version installed of node-fech must be "<=2.6.7"

I can create a pull request in the readme file If you want.

@antoniovlx OK thanks for your comment. Can you make a PR to modify the Electron Quirks and add you in the list of contributors in the readme.md file and i will merge the PR