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 4 years ago
- Reactions: 56
- Comments: 15
Commits related to this issue
- Fix #9880 Fix formatting error on webpack v5, as described here: #9880 Specifically in [this link](https://webpack.js.org/blog/2020-10-10-webpack-5-release/#minor-changes), on the item that says: ... — committed to femesq/create-react-app by femesq 4 years ago
- feat(node_modules): add patch to react-dev-utils This is meant to be a temporary fix until this issue is not solved: https://github.com/facebook/create-react-app/issues/9880 — committed to pagarme/react-scripts-former-kit-dashboard by vagrantsn 3 years ago
- feat(node_modules): add patch to react-dev-utils This is meant to be a temporary fix until this issue is not solved: https://github.com/facebook/create-react-app/issues/9880 — committed to pagarme/react-scripts-former-kit-dashboard by vagrantsn 3 years ago
- feat(node_modules): add patch to react-dev-utils This is meant to be a temporary fix until this issue is not solved: https://github.com/facebook/create-react-app/issues/9880 — committed to pagarme/react-scripts-former-kit-dashboard by vagrantsn 3 years ago
For those waiting for the fix to be accepted, you can use a
postinstall
script like this:tools/postinstall.js
:and on you
package.json
, add this to thescripts
section:@Lyfme you shouldn’t change the module code. Instead, change the input format:
From:
To:
The
formatWebpackMessages
plugin, according to this link, expects an object with 2 props, thus you can push these directly with the expected format.Hope that helps.
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
I have the same question.And I can’t modify the formatWebpackMessages.js in everyone’node_modules of the team.Please upgrade soon.
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.js
It 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 function
becase formating webpack messages is not compatible with webpack 5 Thanks