create-react-app: [V4] Message formatting is incompatible with Webpack v5
TypeError: message.split is not a function
error occurs when webpack throws any error during compilation
Seems like this line should check if message is an object with and message key, as webpack v5 mentions in migration guide:
Stats json errors and warnings no longer contain strings but objects with information splitted into properties.
MIGRATION: Access the information on the properties. i. e. message
Environment
webpack: “5.2.0” react-dev-utils: “11.0.0”
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 56
- Comments: 15
For those waiting for the fix to be accepted, you can use a
postinstallscript like this:tools/postinstall.js:and on you
package.json, add this to thescriptssection:@Lyfme you shouldn’t change the module code. Instead, change the input format:
From:
To:
The
formatWebpackMessagesplugin, according to this link, expects an object with 2 props, thus you can push these directly with the expected format.Hope that helps.
I have the same question.And I can’t modify the formatWebpackMessages.js in everyone’node_modules of the team.Please upgrade soon.
Got another workaround without modifying files in node_modules. It changes webpack.stats.toJson() errors and warning arrays from objects to strings. It’s a webpack plugin that should be added to the array of plugins in your webpack config
Would it also be possible to fix this for version 11.x so as not to introduce the other breaking changes that are a part of version 12.x? My use-case is I’m in a yarn 2 monorepo setup sharing react-dev-utils across workspaces.
When I change:
into:
In:
node_modules\react-dev-utils\formatWebpackMessages.jsIt works again for me.Hopefully, it will be fixed soon 😃
@filipmacek, @darrylsepeda You can use version 12.0.0-next.47. This bug is fixed there
This issue already closed, but I still encounter it even with the latest version of react-dev-utils…
When we can hope to see getting this resolved. It really easy fix. I am getting tired of inserting
message = message.message;everytime I got errormesssage.split is not a functionbecase formating webpack messages is not compatible with webpack 5 Thanks