Skip to content

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

@antoniovlx

Description

@antoniovlx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions