-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
yarn build failed with a fresh created react ts app #11929
yarn build failed with a fresh created react ts app #11929
Comments
I had the same error using npm. Here is my package.json {
"name": "personal-website",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"web-vitals": "^2.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
And here is the error:
|
Same error with npm run build command: ` new MiniCssExtractPlugin({ TypeError: MiniCssExtractPlugin is not a constructor Node.js v17.2.0` |
Problem is a change in the api coming from mini-css-extract-plugin which is versioned at ^2.4.5 in the react-scripts package. It resolves to 2.5.0 at react-scripts install time which isn't good. You can patch around this with this in your package.json temporarily.
I suspect mini-css-extract-plugin should have major-version-bumped if they're going to change their api that much. |
that didn't fix the error for me |
... you do need to do a 'yarn install' or the like to re-resolve and make sure that the current |
Just try to edit /node_modules/react-scripts/config/webpack.config.js in line 19: It works for me :) |
Thanks, It works! |
You're not wrong, but you're also hacking edits into node_modules which is not a sustainable path for deployable software. |
Easy fix if you are a new developer, or just not very good with node_modules or if you're like me and just don't get the lango the others are speaking: Delete "mini-css-extract-plugin" from your node_modules folder. |
This seems to be the best fix right now. Thanks, guys! |
Thank's it is working for me (I tried with 2.4.7 too). Good workaround, waiting for a fix. It may be good thing to temporary lock the release of mini-css between 2.4.5 and 2.5 in the react-scripts package.json. |
Describe the bug
After creating a fresh new app using
yarn create react-app my-app --template typescript
the build process failed with an error frommy_project/node_modules/react-scripts/config/webpack.config.js:664
Based on last releases of all componants inside node 16.13.0
Error is:
Did you try recovering your dependencies?
Yes, getting de fresh project from git or from scratch, see "Steps to reproduce"
Environment
Steps to reproduce
Easy to reproduce craete a fresh new project like this :
Using yarn start, the dev mode is working fine.
Expected behavior
A built app.
Actual behavior
Build failed and the app is not ready for production.
The text was updated successfully, but these errors were encountered: