Skip to content

lib not supported for the html-encoding-sniffer #13

Description

@nooperpudd

issue

require() of ES Module /var/task/node_modules/@exodus/bytes/encoding-lite.js from /var/task/node_modules/html-encoding-sniffer/lib/html-encoding-sniffer.js not supported. Instead change the require of encoding-lite.js in /var/task/node_modules/html-encoding-sniffer/lib/html-encoding-sniffer.js to a dynamic import() which is available in all CommonJS modules.

Activity

  1. ChALkeR commented on Dec 30, 2025

    @ChALkeR
    Collaborator

    @nooperpudd Which Node.js version is this on?

  2. nooperpudd commented on Dec 30, 2025

    @nooperpudd
    Author

    Node v22.20.0

  3. ChALkeR commented on Dec 31, 2025

    @ChALkeR
    Collaborator

    This should not be happening on 22.20
    This is ERR_REQUIRE_ESM, which was deprecated in v20.19.0 / v22.12.0
    Unless Node.js is run explicitly with --no-experimental-require-module, this should not be reachable

    @nooperpudd How can I reproduce this / could you share a minimial setup how to observe this on 22.20?

  4. nooperpudd commented on Dec 31, 2025

    @nooperpudd
    Author

    I just upgraded the node package nuxt-i18n-micro to v2.16.3. and the dependencies package version is jsdom (6.0.0)

  5. ChALkeR commented on Jan 2, 2026

    @ChALkeR
    Collaborator

    @nooperpudd Could you setup a repo to demonstrate this issue?
    jsdom 6.0.0 should be unrelated and does not pull in @exodus/bytes anywhere in its dependency tree

  6. hvaughan3 commented on Jan 2, 2026

    @hvaughan3

    I see the same error but only when running on AWS Lambda using node 22 as well. This was working just fine with new builds from 2 weeks ago. Its only the build I ran on the 31st. Seems like something changed in a dependency between that time. I did not update any libraries in our project explicitly though I see jsdom went from 27.3.0 to 27.4.0 in that time so that is probably what did it.

    *Edit: Forcing jsdom back down to 27.3.0 fixed it for this error. Ended up having to overriding parse5 down to v7 also for something similar.

  7. ChALkeR commented on Jan 3, 2026

    @ChALkeR
    Collaborator

    @hvaughan3

    1. What is the exact Node.js version this is happening on?
    2. Do you have a way to reproduce this that you could share? (ideally a repo or a gist)
  8. frodeaa commented on Jan 3, 2026

    @frodeaa

    It happens with node@24 when loaded as transitive dependency via jsdom

    => Found "jsdom@27.4.0"
    => Found "@exodus/bytes@1.6.0"
    info Reasons this module exists
       - "jsdom" depends on it
       - Hoisted from "jsdom#@exodus#bytes"
       - Hoisted from "jsdom#html-encoding-sniffer#@exodus#bytes"
    info Disk size without dependencies: "432KB"
    info Disk size with unique dependencies: "432KB"
    info Disk size with transitive dependencies: "432KB"
    info Number of shared dependencies: 0
    
    Error [ERR_REQUIRE_ESM]: require() of ES Module /var/task/node_modules/@exodus/bytes/encoding-lite.js from /var/task/node_modules/html-encoding-sniffer/lib/html-encoding-sniffer.js not supported.
    Instead change the require of encoding-lite.js in /var/task/node_modules/html-encoding-sniffer/lib/html-encoding-sniffer.js to a dynamic import() which is available in all CommonJS modules.
        at TracingChannel.traceSync (node:diagnostics_channel:328:14)
        at Object.<anonymous> (/var/task/node_modules/html-encoding-sniffer/lib/html-encoding-sniffer.js:2:41)
    
  9. ChALkeR commented on Jan 3, 2026

    @ChALkeR
    Collaborator

    @frodeaa once again: could you share a repo or gist to reproduce this?

    ERR_REQUIRE_ESM is deprecated since Node.js >=22.12.0 | ^20.19.0, for all Node.js versions that jsdom or @exodus/bytes supports (as specified in engines), and should not be triggered outside of special conditions (like purposely enabling it via a Node.js flag).

    Node.js documentation link: https://nodejs.org/docs/latest/api/errors.html#err_require_esm

    If this can be reproduced outside of those conditions on supported Node.js versions, this needs a specific reproducible example of conditions in which this happens.

  10. frodeaa commented on Jan 3, 2026

    @frodeaa

    @ChALkeR Reproduced with https://github.com/frodeaa/exodus-html-encoding-sniffe

    node --version
    v24.12.0
    
    npm install && npm run build
    node -e "const m = require('./dist/handler.js'); m.handler()"
    

    Unable to reproduce it directly with node, only when loaded via AWS Lambda container,
    so it is not clear what can be done to "fix" this

  11. ChALkeR commented on Jan 3, 2026

    @ChALkeR
    Collaborator

    Thanks!
    This being AWS Lamdba specific explains things, they indeed purposely disabled Node.js default behavior for ESM loading.

    See https://docs.aws.amazon.com/lambda/latest/dg/lambda-nodejs.html#nodejs-experimental-features on how to restore it.
    It's the default behavior in RC status.

    Image

    Moreover, @exodus/bytes doesn't use require(ESM) itself, it's just ESM-only.
    You can't require() it if you have synchronous ESM loader disabled.


    Upd: as of 2026-02-20, it's marked as Stable

    Image
  12. ChALkeR commented on Jan 3, 2026

    @ChALkeR
    Collaborator

    See also jsdom/jsdom@ebad33c, discussion in jsdom/jsdom#3961, jsdom/jsdom#3959
    jsdom already relies on require(esm) to work.

  13. ChALkeR commented on Jan 3, 2026

    @ChALkeR
    Collaborator

    See also discussion at Vercel and their docs

    Also, this thread

  14. hvaughan3 commented on Jan 3, 2026

    @hvaughan3

    Ah that makes sense. Appreciate the help! I will give that a try Monday. Apologies for not getting back to you on it earlier.

  15. added
    questionFurther information is requested
    and removed on Jan 5, 2026
  16. ChALkeR commented on Jan 5, 2026

    @ChALkeR
    Collaborator

    Unless more context is provided (e.g. with cases not related to AWS Lambda) this is answered
    Will reopen if more scenarios arise

  17. ChALkeR commented on Jan 17, 2026

    @ChALkeR
    Collaborator

    Also the very reason for why this was removed in AWS is now gone.
    require(ESM) is marked as stable in Node.js in the current form.

    nodejs/node#60959

  18. ChALkeR commented on Jan 19, 2026

    @ChALkeR
    Collaborator

    require(ESM) is now marked as stable in Node.js

    Image
  19. mtlaso commented on Feb 26, 2026

    @mtlaso

    See also discussion at Vercel and their docs

    Also, this thread

    Thanks, adding NODE_OPTIONS=--experimental-require-module to vercel environment variables made it finally work for me

  20. ChALkeR commented on Feb 26, 2026

    @ChALkeR
    Collaborator

    @mtlaso Ideally, AWS Lambda should stop breaking Node.js configuration.
    They just caused a lot of confusion for everyone without a good reason.

    Also, require(ESM) is stable in Node.js and is not going away (contrary to AWS doc)

  21. ChALkeR commented on Mar 2, 2026

    @ChALkeR
    Collaborator

    Linking: nodejs/node#52697 (comment) (and links below that comment)

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

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions