Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: The requested module 'cheerio' does not provide an export named 'default' #4103

Open
dimaslanjaka opened this issue Sep 20, 2024 · 0 comments

Comments

@dimaslanjaka
Copy link

dimaslanjaka commented Sep 20, 2024

I'am running on NodeJS v20 with ESM to compile this module into electron builder. got this error:

import cheerio from "cheerio"; // load is named export, so wrapping in a default import
       ^^^^^^^
SyntaxError: The requested module 'cheerio' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:146:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:229:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Node.js v20.17.0
  • when i using load import import { load } from 'cheerio' when i run test using jest is working, no error. But, when compiled using electron builder got error message like
TypeError: Cannot destructure property

it should be

import cheerio from 'cheerio';
const { load } = cheerio;
  • when i using default import below
import cheerio from 'cheerio';

// rest of codes
const $ = cheerio.load('string html');

Error when using jest or direct nodejs run (node filename.js), but no error message showing on compiled electron (but the html parsing not working at all). here screenshoot.

image

how to fix this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant