Closed Vercjames closed 11 months ago
Having the same issue.
$ yarn storybook
yarn run v1.22.19
$ storybook dev -p 6006
/home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/cli-table3/src/utils.js:1
const stringWidth = require('string-width');
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/string-width/index.js from /home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/cli-table3/src/utils.js not supported.
Instead change the require of index.js in /home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/cli-table3/src/utils.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/cli-table3/src/utils.js:1:21)
at Object.<anonymous> (/home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/cli-table3/src/table.js:2:15)
at Object.<anonymous> (/home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/cli-table3/index.js:1:18)
at Object.<anonymous> (/home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/@storybook/core-server/dist/index.js:113:8215)
at Object.<anonymous> (/home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/@storybook/cli/dist/generate.js:11:4494)
at Object.<anonymous> (/home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/@storybook/cli/bin/index.js:9:1)
at Object.<anonymous> (/home/myuser/dev/MyRepo/solutions/MyRepo.UI/node_modules/storybook/index.js:3:1) {
code: 'ERR_REQUIRE_ESM'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Same issue.
Stack: vite, typescript, react
storybook 7.3.0
@drush @james-arawhanui @Vercjames Check out this conversation on storybook.
There hasn't been a change to cli-table3 to introduce this issue so it's unclear where/why this is occurring.
cli-table3 defines it's dependency on string-width
as ^4.2.0
. Version 4.x is not an ESM.
It seems like somehow a version of string-width
that is version 5+ is getting installed.
Converting cli-table3 to a module would be a breaking change that I don't have time for presently.
I'm only vaguely familiar with storybook, so information on how this issue can be reproduced more basically would help me find a resolution.
@drush @james-arawhanui @Vercjames Check out this conversation on storybook.
Based on this discussion, this issue appears to be related with yarn version 1 and not directly related to cli-table3—which confirms my hunch that an incorrect version of string-width
is getting installed/linked.
Please review the conversation on storybook and if the issue persists—reopen this issue with instructions on how to reproduce without storybook.
Issue when trying to install and use cil-table3
require() of ES Module /node_modules/string-width/index.js from node_modules/cli-table3/src/utils.js not supported.