Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

Issue when building with rspack and TypeScript 5.x: "Cannot find module 'events'" #715

@rudolfolah

Description

@rudolfolah

I'm building project that uses sanitize-html, which relies on htmlparser2.

The error during the rspack build was this:

ERROR in ./node_modules/sanitize-html-react/node_modules/htmlparser2/lib/Parser.js 133:28-58
  ❌ Module not found: Can't resolve 'events' in ...
[133:28]
}

require("inherits")(Parser, require("events").EventEmitter);

Parser.prototype._updatePosition = function(initialOffset) {

The fix that I found was to install the events package.

From what I can see, the package is using the 8.x version of htmlparser2, and the latest version of htmlparser2 is 10.x. I do not know if a version upgrade would fix the issue.

A mention of this in the README, that the "events" module is needed if it isn't part of the bundler/build system, could be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions