Skip to content

Commit 98b1024

Browse files
committed
Update extractor.ts
1 parent 0589b62 commit 98b1024

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/extractor.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44

55
import TurndownService from 'turndown';
66
import { gfm } from 'turndown-plugin-gfm';
7-
import * as cheerio from 'cheerio';
7+
import cheerioDefault from 'cheerio';
8+
import * as cheerioNamespace from 'cheerio';
89
import type { CheerioAPI } from 'cheerio';
910
import { ExtractionSchema, ScrapedData } from './types';
1011

12+
// Support both ESM default (macOS/Node) and CJS namespace (Windows/Ubuntu)
13+
const cheerio = (cheerioDefault?.load != null) ? cheerioDefault : cheerioNamespace;
14+
1115
export class DataExtractor {
1216
private turndown: TurndownService;
1317
private schema?: ExtractionSchema;

0 commit comments

Comments
 (0)