Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Build Storybook 7.1.0 fails with ERR_REQUIRE_ESM #23551

Closed
D3strukt0r opened this issue Jul 21, 2023 · 1 comment
Closed

[Bug]: Build Storybook 7.1.0 fails with ERR_REQUIRE_ESM #23551

D3strukt0r opened this issue Jul 21, 2023 · 1 comment

Comments

@D3strukt0r
Copy link

D3strukt0r commented Jul 21, 2023

Describe the bug

I get following in my Companies CI pipeline

/usr/src/app/node_modules/cli-table3/src/utils.js:1
const stringWidth = require('string-width');
                    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /usr/src/app/node_modules/string-width/index.js from /usr/src/app/node_modules/cli-table3/src/utils.js not supported.
Instead change the require of index.js in /usr/src/app/node_modules/cli-table3/src/utils.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/usr/src/app/node_modules/cli-table3/src/utils.js:1:21)
    at Object.<anonymous> (/usr/src/app/node_modules/cli-table3/src/table.js:2:15)
    at Object.<anonymous> (/usr/src/app/node_modules/cli-table3/index.js:1:18)
    at Object.<anonymous> (/usr/src/app/node_modules/@storybook/core-server/dist/index.js:113:7796)
    at Object.<anonymous> (/usr/src/app/node_modules/@storybook/cli/dist/generate.js:11:4494)
    at Object.<anonymous> (/usr/src/app/node_modules/@storybook/cli/bin/index.js:9:1)
    at Object.<anonymous> (/usr/src/app/node_modules/storybook/index.js:3:1) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.17.0
error Command failed with exit code 1.

To Reproduce

I had updated everything else and it still worked, when I got to upgrade storybook, I get the error above.

This is my package.json

{
    "name": "inventarly",
    "version": "0.0.1",
    "license": "UNLICENSED",
    "type": "module",
    "scripts": {
        "postinstall": "patch-package",
        "dev:ts": "tsc --watch --noEmit",
        "dev:storybook": "storybook dev --port 6006 --https --ssl-cert ./docker/run/certificates/cert.pem --ssl-key ./docker/run/certificates/key.pem",
        "dev:app": "cross-env BROWSERSLIST_ENV=development vite",
        "dev": "npm-run-all --parallel dev:*",
        "ts:check": "tsc --noEmit",
        "app:build": "vite build",
        "build:storybook": "storybook build --output-dir ./public/storybook",
        "build:app": "npm-run-all --serial ts:check app:build",
        "build": "npm-run-all --parallel build:*"
    },
    "dependencies": {
        "@babel/core": "^7.13.0",
        "@babel/plugin-syntax-flow": "^7.14.5",
        "@babel/plugin-transform-react-jsx": "^7.14.9",
        "@emotion/react": "^11.11.0",
        "@emotion/styled": "^11.11.0",
        "@fortawesome/fontawesome-svg-core": "^6.2.1",
        "@fortawesome/pro-light-svg-icons": "^6.2.1",
        "@fortawesome/pro-regular-svg-icons": "^6.2.1",
        "@fortawesome/react-fontawesome": "^0.2.0",
        "@loadable/component": "^5.15.3",
        "@mui/material": "^5.13.1",
        "@redux-devtools/extension": "^3.2.3",
        "@reduxjs/toolkit": "^1.9.0",
        "@sentry/browser": "^7.21.1",
        "@storybook/addon-essentials": "^7.0.5",
        "@storybook/addon-interactions": "^7.0.5",
        "@storybook/addon-links": "^7.0.5",
        "@storybook/blocks": "^7.0.5",
        "@storybook/react": "^7.0.5",
        "@storybook/react-vite": "^7.0.5",
        "@storybook/testing-library": "^0.1.0",
        "@swc/helpers": "^0.5.0",
        "@textea/json-viewer": "^3.0.0",
        "@types/loadable__component": "^5.13.4",
        "@types/lodash": "^4.14.194",
        "@types/node": "^18.11.9",
        "@types/object-hash": "^3.0.2",
        "@types/react": "^18.0.25",
        "@types/react-dom": "^18.0.9",
        "@types/react-text-truncate": "^0.14.1",
        "@typescript-eslint/eslint-plugin": "^5.44.0",
        "@typescript-eslint/parser": "^5.44.0",
        "@vitejs/plugin-react": "^4.0.0",
        "add": "^2.0.6",
        "antd": "^5.4.7",
        "autoprefixer": "^10.4.14",
        "axios": "^1.2.0",
        "browserslist": "^4.21.4",
        "browserslist-to-esbuild": "^1.2.0",
        "chalk": "^5.2.0",
        "classnames": "^2.3.2",
        "core-js": "^3.26.1",
        "cross-env": "^7.0.3",
        "dayjs": "^1.11.6",
        "dotenv": "^16.0.3",
        "eslint": "^8.28.0",
        "eslint-config-airbnb": "^19.0.4",
        "eslint-config-prettier": "^8.5.0",
        "eslint-config-react-app": "^7.0.1",
        "eslint-import-resolver-alias": "^1.1.2",
        "eslint-import-resolver-typescript": "^3.5.5",
        "eslint-plugin-import": "^2.26.0",
        "eslint-plugin-jsx-a11y": "^6.6.1",
        "eslint-plugin-prettier": "^4.2.1",
        "eslint-plugin-react": "^7.31.11",
        "eslint-plugin-react-hooks": "^4.6.0",
        "eslint-plugin-storybook": "^0.6.11",
        "i18next": "^22.0.6",
        "i18next-browser-languagedetector": "^7.0.1",
        "i18next-http-backend": "^2.0.2",
        "immer": "^10.0.1",
        "interweave": "^13.0.0",
        "lodash": "^4.17.21",
        "npm-run-all": "^4.1.5",
        "object-hash": "^3.0.0",
        "patch-package": "^7.0.0",
        "postcss": "^8.4.23",
        "postcss-scss": "^4.0.6",
        "postinstall-postinstall": "^2.1.0",
        "prettier": "^2.8.0",
        "prop-types": "^15.8.1",
        "query-string": "^8.1.0",
        "rc-picker": "^3.2.4",
        "rc-select": "^14.4.3",
        "react": "^18.2.0",
        "react-dom": "^18.2.0",
        "react-dropdown": "^1.11.0",
        "react-i18next": "^12.0.0",
        "react-is": "^18.2.0",
        "react-redux": "^8.0.5",
        "react-refresh": "^0.14.0",
        "react-router-dom": "^6.4.3",
        "react-text-truncate": "^0.19.0",
        "redux": "^4.2.0",
        "redux-thunk": "^2.4.2",
        "require-from-string": "^2.0.2",
        "sass": "^1.62.1",
        "storybook": "^7.0.5",
        "stylelint": "^15.5.0",
        "stylelint-config-standard": "^33.0.0",
        "stylelint-config-standard-scss": "^9.0.0",
        "stylelint-scss": "^5.0.0",
        "tailwindcss": "^3.3.2",
        "type-fest": "^3.2.0",
        "typescript": "^5.0.4",
        "vite": "^4.0.4",
        "vite-plugin-chunk-split": "^0.4.7",
        "vite-plugin-restart": "^0.3.1",
        "vite-plugin-svgr": "^3.2.0",
        "vite-plugin-symfony": "^0.7.5",
        "web-vitals": "^3.1.0"
    },
    "private": true
}

I don't patch anything currently. I tried updating everything so you can probably just do a yarn install

System

Can't as it's on the CI, but it's the latest node 18 version

Additional context

No response

@valentinpalkovic
Copy link
Contributor

Duplicate of: #22431. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants