Skip to content

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

Closed

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.

Activity

  1. jepiqueau commented on Nov 18, 2022

    @jepiqueau
    Collaborator

    @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

  2. locked as resolved and limited conversation to collaborators on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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