cz-cli icon indicating copy to clipboard operation
cz-cli copied to clipboard

regression: Pnpm `wrap-ans` require() of ES Module error

Open MengLinMaker opened this issue 5 months ago • 0 comments

Description

cz-cli dependency wrap-ans does not import properly, causing error when running pnpm commit

package.json

{
  "type": "module",
  "scripts": {
      "commit": "cz",
      ...
    },
    ...
}

error in cli

require() of ES Module /Users/menglinmaker/Documents/2-Engineering/OpenSource/npm-library-boilerplate/node_modules/wrap-ansi/node_modules/string-width/index.js from /Users/menglinmaker/Documents/2-Engineering/OpenSource/npm-library-boilerplate/node_modules/wrap-ansi/index.js not supported.
Instead change the require of /Users/menglinmaker/Documents/2-Engineering/OpenSource/npm-library-boilerplate/node_modules/wrap-ansi/node_modules/string-width/index.js in /Users/menglinmaker/Documents/2-Engineering/OpenSource/npm-library-boilerplate/node_modules/wrap-ansi/index.js to a dynamic import() which is available in all CommonJS modules.

Note: using "type": "commonjs" leads to the same result

Additional details

This issue only occurs on [email protected] and after. I found [email protected] to behave exactly how I liked.

MengLinMaker avatar Sep 01 '24 13:09 MengLinMaker