Created
April 14, 2021 08:33
-
-
Save mucahitgurbuz/3a18d87e763a28a97e872be2943a5820 to your computer and use it in GitHub Desktop.
Fix for "TypeError: message.split is not a function" error for Webpack 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a temporary fix for open issue https://github.com/facebook/create-react-app/issues/9880 | |
const replace = require('replace-in-file'); | |
const fixFormatWebpackMessages = async () => { | |
try { | |
const results = await replace({ | |
files: 'node_modules/react-dev-utils/formatWebpackMessages.js', | |
from: `let lines = message.split('\\n');`, | |
to: `let lines = []; | |
if (typeof message === 'string' || message instanceof String) { | |
lines = message.split('\\n'); | |
} else if ('message' in Object.keys(message)) { | |
lines = message['message'].split('\\n'); | |
}`, | |
}); | |
} catch (e) { | |
console.log('error while trying to fix "formatWebpackMessages.js"', e); | |
} | |
}; | |
fixFormatWebpackMessages(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment