Skip to content

[Bug?]: Error [ERR_REQUIRE_ESM]: require() of ES Module string-width/index.js #8994

Open
@Sitting-Duck351

Description

@Sitting-Duck351

Self-service

  • I'd be willing to implement a fix

Describe the bug

Everything was working with string-width v3.2.3, until v5.0.1 was added to yarn.lock, after then I get:

  • Error [ERR_REQUIRE_ESM]: require() of ES Module <path>/node_modules/string-width/index.js

As workaround I use NPM, which adds the name to v4.2.3 and then yarn import to generate yarn.lock, since my pipeline is all based in yarn. Or if I add name string-width to v4.2.3 manually then it works.

This issue is already reported in storybookjs github:
[https://github.com/storybookjs/storybook/issues/22431]

To reproduce

Having string-width v4.2.3 and v5.0.1 in yarn.lock, run yarn --pure-lockfile

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==
dependencies:
eastasianwidth "^0.2.0"
emoji-regex "^9.2.2"
strip-ansi "^7.0.1"

Environment

Node: 16.14.0
Yarn: 1.22.19
Npm: 8.5.0

Additional context

No response

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