← All tasks
javascriptinikulin/parse5 #663Not a task: not reproduced

require() of ES modules is not supported

envgap__inikulin__parse5-663

01 / FAILURE SIGNATURE

As reported upstream

parse5 is being used by puppeteer and I get this error in the latest version(7.1.0) of parse5 (via puppeteer)
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
2d63a63b4f08676c26959e5169e524ea585c8db5
Manifest
packages/parse5-htmlparser2-tree-adapter/package.json
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

inikulin/parse5 #663 · read the original issue
parse5 is being used by puppeteer and I get this error in the latest version(7.1.0) of parse5 (via puppeteer)





```

internal/modules/cjs/loader.js:1253

      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);

      ^



Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /data/agents/agent31/_work/10/s/.npm-global/lib/node_modules/aws-azure-login/node_modules/parse5/dist/cjs/index.js

require() of ES modules is not supported.

require() of /data/agents/agent31/_work/10/s/.npm-global/lib/node_modules/aws-azure-login/node_modules/parse5/dist/cjs/index.js from /data/agents/agent31/_work/10/s/.npm-global/lib/node_modules/aws-azure-login/node_modules/cheerio/lib/parsers/parse5-adapter.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.

Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /data/agents/agent31/_work/10/s/.npm-global/lib/node_modules/aws-azure-login/node_modules/parse5/package.json.



    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1253:13)

    at Module.load (internal/modules/cjs/loader.js:1085:32)

    at Function.Module._load (internal/modules/cjs/loader.js:950:14)

    at Module.require (internal/modules/cjs/loader.js:1125:19)

    at require (internal/modules/cjs/helpers.js:75:18)

    at Object.<anonymous> (/data/agents/agent31/_work/10/s/.npm-global/lib/node_modules/aws-azure-login/node_modules/cheerio/lib/parsers/parse5-adapter.js:14:16)

    at Module._compile (internal/modules/cjs/loader.js:1236:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)

    at Module.load (internal/modules/cjs/loader.js:1085:32)

    at Function.Module._load (internal/modules/cjs/loader.js:950:14)

    at Module.require (internal/modules/cjs/loader.js:1125:19)

    at require (internal/modules/cjs/helpers.js:75:18)

    at Object.<anonymous> (/data/agents/agent31/_work/10/s/.npm-global/lib/node_modules/aws-azure-login/node_modules/cheerio/lib/index.js:41:27)

    at Module._compile (internal/modules/cjs/loader.js:1236:30)

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1257:10)

    at Module.load (internal/modules/cjs/loader.js:1085:32) {

  code: 'ERR_REQUIRE_ESM'

}

```
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]