You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The @storybook/test package has different exported versions (entry points): ./dist/index.js and ./dist/index.mjs as described in its package.json file:
When it resolves to the ./dist/index.js version, starting/building Storybook breaks because it requires some Node.JS core modules (os and tty) that are not present in the ./dist/index.mjs version:
=> Failed to build the preview
SB_BUILDER-WEBPACK5_0002 (WebpackInvocationError): Module not found: Error: Can't resolve 'tty' in '/path/to/repository/node_modules/@storybook/test/dist'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "tty": require.resolve("tty-browserify") }'
- install 'tty-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "tty": false }
As to the logic leading to load one version or the other, it could depend on multiple factors, according to the spec.
In our case, we are using the following Webpack config:
Describe the bug
The
@storybook/test
package has different exported versions (entry points):./dist/index.js
and./dist/index.mjs
as described in itspackage.json
file:When it resolves to the
./dist/index.js
version, starting/building Storybook breaks because it requires some Node.JS core modules (os
andtty
) that are not present in the./dist/index.mjs
version:As to the logic leading to load one version or the other, it could depend on multiple factors, according to the spec.
In our case, we are using the following Webpack config:
Which makes Webpack use the
exports
field instead of themodule
field when available.Now, this issue could be seen from different angles:
exports
field should be reviewed.os
andtty
required in a package that should/could run in a browser?Without going into the above details, I would suggest the following easy fix:
Or the following if both entry points are meant for node and browser respectively:
The order is very important.
To Reproduce
Configure your bundler to use
exports
, for example, using Webpack:Then just build your Storybook.
System
Additional context
N/A
The text was updated successfully, but these errors were encountered: