[GH-ISSUE #4816] [BUG]: Collector web scraping fails with ERR_REQUIRE_ESM in string-width/cliui (Puppeteer fallback triggered) #3034

Closed
opened 2026-02-22 18:32:21 -05:00 by yindo · 2 comments
Owner

Originally created by @javaheripur on GitHub (Dec 31, 2025).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4816

How are you running AnythingLLM?

Docker (local)

What happened?

When attempting to scrape a webpage (tested with https://example.com) via the AnythingLLM UI (Documents → Add document → Fetch website), the collector service fails to use Puppeteer for content extraction and falls back to a basic fetch method.
The failure occurs in the Puppeteer-based loader (PuppeteerWebBaseLoader from LangChain.js), which is invoked during the scraping process (getPageContent → scrapeGenericUrl → processLink).
Instead of successfully launching a headless browser or loading the page, the process crashes with the following root error:

Error [ERR_REQUIRE_ESM]: require() of ES Module /app/collector/node_modules/string-width/index.js from /app/collector/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js in /app/collector/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/app/collector/node_modules/cliui/build/index.cjs:291:21)
    at Object.<anonymous> (/app/collector/node_modules/yargs/build/index.cjs:1:60678)
    at async PuppeteerWebBaseLoader.imports (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:123:32)
    at async PuppeteerWebBaseLoader._scrape (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:41:28)
    at async PuppeteerWebBaseLoader.load (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:74:22)
    at async getPageContent (/app/collector/processLink/convert/generic.js:210:18)
    ...

This error happens because:

cliui (a CommonJS module, pulled in via yargs) attempts a synchronous require('string-width').
A version of string-width ≥5.0.0 (ESM-only) has been resolved in the dependency tree.
CommonJS require() cannot load pure ESM modules, triggering ERR_REQUIRE_ESM.

As a direct result of this crash during the dynamic import/loading phase of Puppeteer dependencies, the PuppeteerWebBaseLoader.imports check fails. The AnythingLLM collector code then logs the misleading fallback message:

[collector] error: getPageContent failed to be fetched by puppeteer - falling back to fetch! Error: Please install puppeteer as a dependency with, e.g. `yarn add puppeteer`

Puppeteer itself is present in the official mintplexlabs/anythingllm:latest Docker image (bundled during build), but the loader never reaches browser launch due to the earlier ESM incompatibility error in the dependency chain.

Are there known steps to reproduce?

No response

Originally created by @javaheripur on GitHub (Dec 31, 2025). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/4816 ### How are you running AnythingLLM? Docker (local) ### What happened? When attempting to scrape a webpage (tested with https://example.com) via the AnythingLLM UI (Documents → Add document → Fetch website), the collector service fails to use Puppeteer for content extraction and falls back to a basic fetch method. The failure occurs in the Puppeteer-based loader (PuppeteerWebBaseLoader from LangChain.js), which is invoked during the scraping process (getPageContent → scrapeGenericUrl → processLink). Instead of successfully launching a headless browser or loading the page, the process crashes with the following root error: ``` Error [ERR_REQUIRE_ESM]: require() of ES Module /app/collector/node_modules/string-width/index.js from /app/collector/node_modules/cliui/build/index.cjs not supported. Instead change the require of index.js in /app/collector/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/app/collector/node_modules/cliui/build/index.cjs:291:21) at Object.<anonymous> (/app/collector/node_modules/yargs/build/index.cjs:1:60678) at async PuppeteerWebBaseLoader.imports (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:123:32) at async PuppeteerWebBaseLoader._scrape (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:41:28) at async PuppeteerWebBaseLoader.load (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:74:22) at async getPageContent (/app/collector/processLink/convert/generic.js:210:18) ... ``` This error happens because: cliui (a CommonJS module, pulled in via yargs) attempts a synchronous require('string-width'). A version of string-width ≥5.0.0 (ESM-only) has been resolved in the dependency tree. CommonJS require() cannot load pure ESM modules, triggering ERR_REQUIRE_ESM. As a direct result of this crash during the dynamic import/loading phase of Puppeteer dependencies, the PuppeteerWebBaseLoader.imports check fails. The AnythingLLM collector code then logs the misleading fallback message: ``` [collector] error: getPageContent failed to be fetched by puppeteer - falling back to fetch! Error: Please install puppeteer as a dependency with, e.g. `yarn add puppeteer` ``` Puppeteer itself is present in the official mintplexlabs/anythingllm:latest Docker image (bundled during build), but the loader never reaches browser launch due to the earlier ESM incompatibility error in the dependency chain. ### Are there known steps to reproduce? _No response_
yindo added the possible bug label 2026-02-22 18:32:21 -05:00
yindo closed this issue 2026-02-22 18:32:21 -05:00
Author
Owner

@speedyfoxai commented on GitHub (Jan 2, 2026):

[collector] info: Scraping 1/1: https://docs.openwebui.com
[collector] error: Error [ERR_REQUIRE_ESM]: require() of ES Module /app/collector/node_modules/string-width/index.js from /app/collector/node_modules/cliui/build/index.cjs not supported.
Instead change the require of index.js in /app/collector/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules.
at Object. (/app/collector/node_modules/cliui/build/index.cjs:291:21)
at Object. (/app/collector/node_modules/yargs/build/index.cjs:1:60678)
at async PuppeteerWebBaseLoader.imports (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:123:32)
at async PuppeteerWebBaseLoader._scrape (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:41:28)
at async PuppeteerWebBaseLoader.load (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:74:22)
at async getPageLinks (/app/collector/utils/extensions/WebsiteDepth/index.js:53:18)
at async discoverLinks (/app/collector/utils/extensions/WebsiteDepth/index.js:27:26)
at async websiteScraper (/app/collector/utils/extensions/WebsiteDepth/index.js:158:25)
at async /app/collector/extensions/index.js:124:29
[collector] error: Failed to scrape https://docs.openwebui.com. Error: Please install puppeteer as a dependency with, e.g. yarn add puppeteer
at PuppeteerWebBaseLoader.imports (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:128:19)
at async PuppeteerWebBaseLoader._scrape (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:41:28)
at async PuppeteerWebBaseLoader.load (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:74:22)
at async bulkScrapePages (/app/collector/utils/extensions/WebsiteDepth/index.js:102:20)
at async websiteScraper (/app/collector/utils/extensions/WebsiteDepth/index.js:164:23)
at async /app/collector/extensions/index.js:124:29

@speedyfoxai commented on GitHub (Jan 2, 2026): [collector] info: Scraping 1/1: https://docs.openwebui.com [collector] error: Error [ERR_REQUIRE_ESM]: require() of ES Module /app/collector/node_modules/string-width/index.js from /app/collector/node_modules/cliui/build/index.cjs not supported. Instead change the require of index.js in /app/collector/node_modules/cliui/build/index.cjs to a dynamic import() which is available in all CommonJS modules. at Object.<anonymous> (/app/collector/node_modules/cliui/build/index.cjs:291:21) at Object.<anonymous> (/app/collector/node_modules/yargs/build/index.cjs:1:60678) at async PuppeteerWebBaseLoader.imports (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:123:32) at async PuppeteerWebBaseLoader._scrape (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:41:28) at async PuppeteerWebBaseLoader.load (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:74:22) at async getPageLinks (/app/collector/utils/extensions/WebsiteDepth/index.js:53:18) at async discoverLinks (/app/collector/utils/extensions/WebsiteDepth/index.js:27:26) at async websiteScraper (/app/collector/utils/extensions/WebsiteDepth/index.js:158:25) at async /app/collector/extensions/index.js:124:29 [collector] error: Failed to scrape https://docs.openwebui.com. Error: Please install puppeteer as a dependency with, e.g. `yarn add puppeteer` at PuppeteerWebBaseLoader.imports (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:128:19) at async PuppeteerWebBaseLoader._scrape (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:41:28) at async PuppeteerWebBaseLoader.load (/app/collector/node_modules/langchain/dist/document_loaders/web/puppeteer.cjs:74:22) at async bulkScrapePages (/app/collector/utils/extensions/WebsiteDepth/index.js:102:20) at async websiteScraper (/app/collector/utils/extensions/WebsiteDepth/index.js:164:23) at async /app/collector/extensions/index.js:124:29
Author
Owner

@timothycarambat commented on GitHub (Jan 2, 2026):

Resolved by #4819

@timothycarambat commented on GitHub (Jan 2, 2026): Resolved by #4819
yindo changed title from [BUG]: Collector web scraping fails with ERR_REQUIRE_ESM in string-width/cliui (Puppeteer fallback triggered) to [GH-ISSUE #4816] [BUG]: Collector web scraping fails with ERR_REQUIRE_ESM in string-width/cliui (Puppeteer fallback triggered) 2026-06-05 14:49:56 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#3034