storybook: Error when running build-storybook with Node 17
Describe the bug When I running the cmd line ̀yarn build-storybook -c .storybook -o build/storybook` with Node 17. I received this error:
10% building 1/11 modules 10 active /home/belliard/dev/my-app/node_modules/@storybook/addon-links/dist/esm/preset/addDecorator.js-generated-other-entry.jsnode:internal/crypto/hash:67
this[kHandle] = new _Hash(algorithm, xofLen);
^
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (/home/belliard/dev/my-app/node_modules/@storybook/builder-webpack4/node_modules/webpack/lib/util/createHash.js:135:53)
at NormalModule._initBuildHash (/home/belliard/dev/my-app/node_modules/@storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:417:16)
at handleParseError (/home/belliard/dev/my-app/node_modules/@storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:471:10)
at /home/belliard/dev/my-app/node_modules/@storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:503:5
at /home/belliard/dev/my-app/node_modules/@storybook/builder-webpack4/node_modules/webpack/lib/NormalModule.js:358:12
at /home/belliard/dev/my-app/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/home/belliard/dev/my-app/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at /home/belliard/dev/my-app/node_modules/loader-runner/lib/LoaderRunner.js:205:4
at /home/belliard/dev/my-app/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:85:15
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
}
Node.js v17.0.1
I create a CRA project in order to reproduce the bug, and I get the error. An issue on webpack was opened (#14532) and a workaround was found using
export NODE_OPTIONS=--openssl-legacy-provider
To Reproduce
- Create a react project with CRA
- Run
npx sb init - Run
yarn build-storybook -c .storybook -o build/storybook
System
Environment Info:
System:
OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (12) x64 AMD Ryzen 5 PRO 4650U with Radeon Graphics
Binaries:
Node: 17.0.1 - /usr/local/bin/node
Yarn: 1.22.11 - /usr/bin/yarn
npm: 8.1.0 - /usr/local/bin/npm
Browsers:
Chrome: 95.0.4638.69
Firefox: 93.0
npmPackages:
@storybook/addon-actions: ^6.3.12 => 6.3.12
@storybook/addon-essentials: ^6.3.12 => 6.3.12
@storybook/addon-links: ^6.3.12 => 6.3.12
@storybook/node-logger: ^6.3.12 => 6.3.12
@storybook/preset-create-react-app: ^3.2.0 => 3.2.0
@storybook/react: ^6.3.12 => 6.3.12
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 61
- Comments: 21 (6 by maintainers)
Commits related to this issue
- fix: workaroud for Node v17 and Storybook (ref: https://github.com/storybookjs/storybook/issues/16555) — committed to ninjinkun/blog-feedback-app by ninjinkun 2 years ago
- Fix storybook dev command (#1374) Workaround for https://github.com/storybookjs/storybook/issues/16555. The error "Error: error:0308010C:digital envelope routines::unsupported" is fixed with webpack ... — committed to JabRef/JabRefOnline by tobiasdiez 2 years ago
- Install storybook 6.5 (has issues) Running into issues -- See https://github.com/storybookjs/storybook/issues/16555#issuecomment-1258166062 — committed to zeus-health/ctw-component-library by WesleyKapow 2 years ago
- fix(storybook): nodejs-17+ requires webpack@5+ [1] 1: https://github.com/storybookjs/storybook/issues/16555 — committed to conversionxl/aybolit by lkraav a year ago
- workaround storybook issue https://github.com/storybookjs/storybook/issues/16555 — committed to shun/react-gantt by deleted user a year ago
- chore: use node 16 to avoid storybook/webpack issues https://github.com/webpack/webpack/issues/14532 https://github.com/storybookjs/storybook/issues/16555 — committed to MauricioRobayo/react-obfuscate-email by MauricioRobayo a year ago
- ci: dependabot auto-merge prs (#518) * ci: dependabot auto-merge prs * chore: use node 16 to avoid storybook/webpack issues https://github.com/webpack/webpack/issues/14532 https://github.com/s... — committed to MauricioRobayo/react-obfuscate-email by MauricioRobayo a year ago
- SX Design: patch `build-storybook` script Annoyingly, there is currently an issue with Storybook (see: https://github.com/storybookjs/storybook/issues/16555). We already have to do this in CI to make... — committed to adeira/universe by mrtnzlml a year ago
- SX Design: patch `build-storybook` script Annoyingly, there is currently an issue with Storybook (see: https://github.com/storybookjs/storybook/issues/16555). We already have to do this in CI to make... — committed to adeira/universe by mrtnzlml a year ago
- SX Design: patch `build-storybook` script Annoyingly, there is currently an issue with Storybook (see: https://github.com/storybookjs/storybook/issues/16555). We already have to do this in CI to make... — committed to adeira/sx-design by mrtnzlml a year ago
- build(storybook): fix error when running storybook with Node 18 https://github.com/storybookjs/storybook/issues/16555 — committed to remarkablemark/lerna-template by remarkablemark 8 months ago
This issue seems to remains for with builder-vite, as I understand manager-webpack4 is still used.
More users may run into this issue as node.js 16’s EOL is 7 months ahead of schedule.
I’m temporarily avoiding it by enabling the node environment variable in direnv.
If webpack 4 isn’t patched, perhaps the other solutions listed in this article would resolve the issue for some users:
https://onlinessolution.blogspot.com/2021/11/error-error0308010cdigital-envelope.html
This fixed my problem: https://www.npmjs.com/package/@storybook/manager-webpack5
Removed
@storybook/builder-webpack4and@storybook/manager-webpack4, node_modules and lock files. Then install v5. And follow the instuctions on above link.@hlehmann that’s true in 6.5, but in 7.0 webpack is not used in the vite builder at all. I’d suggest trying out the new alpha version if you’re having issues here.
npx sb@next upgrade --prerelease.(Edited command)
futuredid not work for me This one did:npx sb@next upgrade --prereleaseHi, I’m using webpack
5.65.0, node17.4.0, and storybook6.5.0-alpha.49. I’m encountering this issue. I was able to solve it locally by puttingNODE_OPTIONS=--openssl-legacy-providerat the start of my storybook build/start commands, but this doesn’t work on our CI - the node option is blocked because of security concerns. We will downgrade node to 16 for now, but I want to ask: What are the plans here? Will this be solved by the Storybook team in the future?I got same error with svelte kit project
Thanks, I ran
yarn dedupeinstead of manually editing the lock file and this resolved my issueGetting back 20 minutes later - I actually found a culprit. You were right this is fixed in the new webpack version, the problem was that the
@storybook/builder-webpack5package defines its ownwebpack: ^5.9.0dependency, which inyarn.lockhad an old resolution. So I:"webpack@npm:^5.9.0":part ofyarn.lockyarnto re-resolve dependenciesAfter this, it works.
However, this means the Storybook team should update the
webpackdependency of@storybook/builder-webpack5so other people don’t run into this problem anymore.Adding this configuration to
.storybook/main.tssolved the issue for me;Migrating to webpack 5 did the job for me.
Please note that this command is for fresh installation:
npx sb init --builder webpack5By default storybook installed webpack4 and it was causing the issue