-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
TypeError: Cannot read property 'module' of undefined #5877
Comments
same issue I guess
module.exports = (baseConfig, env, config) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve('babel-loader'),
options: {
presets: [['react-app', { flow: false, typescript: true }]],
},
});
config.resolve.extensions.push('.ts', '.tsx');
return config;
}; |
Logging the three variables in the line I don't have any grasp on what the aforementioned trio of variables are intended to represent, but I did find that changing the enclosing function got me up and running. My const path = require("path");
module.exports = ({ config }) => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
use: [
{
loader: require.resolve("awesome-typescript-loader")
},
{
loader: require.resolve("react-docgen-typescript-loader")
}
]
});
config.resolve.extensions.push(".ts", ".tsx");
return config;
}; |
Thank you Another issue that might crop up afterwards is in
using the default npx install it puts files into |
Any one keen to send a PR to the docs to fix these two things? 🙏 |
Can't get the example with babel-loader to work either! tried some different webpack configs but no luck, it looks like this:
any ideas? |
yes just change to |
@tograd Thanks for your reply! I misunderstood what you said as I'm having a different issue where this bit of code |
@tmeasday: Sure! I would be happy to take a stab at it. It looks to me like this line loads the function provided in a custom I'll submit a PR for the docs accordingly! |
@filiplindbladh: Are you blocked by any error in particular? I just tried using the
|
@jangerhofer For me at least, the issue arises in upgrading Storybook from 4.x to 5 on my existing TypeScript CRA app, per the upgrade guide. |
@jangerhofer |
@DanRYoung did you get this figured out? There was a bug in "extend-mode" webpack config that got fixed in 5.0.2 https://github.com/storybooks/storybook/blob/next/MIGRATION.md#deprecate-webpack-extend-mode |
Thanks everyone for the awesome replies and all the help! You guys are awesome 👍 |
I'm still having this error, I'm not understanding what I need to do to fix it. This is what my webpack.config inside my .storybook looks like.
EDIT: Don't forget you curly braces in ({config, mode}) |
@forrestblade If you're using Storybook 5, the webpack config function signature changed. You're still using the v4 version. See: https://github.com/storybooks/storybook/blob/next/MIGRATION.md#webpack-config-simplification |
I figured, it out. It's been a long day haha. I forgot my curly braces |
For me to make it work with 5.3.x version I had to have my webpack config like this:
|
I'm using the latest Storybook: 5.0.0
I'm using React generated with
create-react-app
with the--typescript
flag. Following this guide; https://storybook.js.org/docs/configurations/typescript-config/#setting-up-typescript-with-babel-loaderI get the following error: TypeError: Cannot read property 'module' of undefined
The text was updated successfully, but these errors were encountered: