You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"TypeError: MiniCssExtractPlugin is not a constructor" in fresh CRA installation #11930
TypeError: MiniCssExtractPlugin is not a constructor
at module.exports (/home/john/Projects/test/node_modules/react-scripts/config/webpack.config.js:664:9)
at Object.<anonymous> (/home/john/Projects/test/node_modules/react-scripts/scripts/build.js:58:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47
Did you try recovering your dependencies?
Clearing package-lock.json and node_modules did not help at all.
└─▪ npm --version
8.3.0
Which terms did you search for in User Guide?
I have been searching for this error for a few hours but I can't find it anywhere. It shouldn't be happening on a fresh installation.
Environment
Environment Info:
current version of create-react-app: 5.0.0
running from /home/john/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app
System:
OS: Linux 5.15 Arch Linux
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 14.18.2 - /usr/bin/node
Yarn: 1.22.17 - /usr/bin/yarn
npm: 8.3.0 - /usr/bin/npm
Browsers:
Chrome: Not Found
Firefox: 96.0
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 5.0.0 => 5.0.0
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
Issue can be replicated easily via
npx create-react-app test
cd test
npm run build
Expected behavior
I expected npm run build to work without errors.
Actual behavior
It produced the error TypeError: MiniCssExtractPlugin is not a constructor instead.
Reproducible demo
git clone https://github.com/jathanasiou/react-mincss-crash.git
cd react-mincss-crash
npm i && npm run build
Reacted by jescoto, Morrisonleary, Alexandru Pavaloi, Dan Bright, Casey Occhialini, Sufyan Motala, Muhammed Rahif, Leandro Arturi, Gergő Radeczki, Novikov Viktor and 30 more
Reacted by Samuel A. Lamb, John Athanasiou, Joshua Stevens, Gani, Andy Hitchman, David Hartsough, Chris, Oli, Daniel Grant, Shinya Fujino and 70 more
Reacted by Radik Ziiangirov, Mohamed Iyed Mansour, Leandro Arturi, Anthony Sokolov, Suprit Shah, Jack Theisen, Susie Stanley, Farrell D., Garrett Fermo, Kwangtae Kim and 3 more
Reacted by Gavin King, Pablo Suárez, Kelson Adams, Honza Němeček, Dom G., JhonSJ, Michael R., Nathan Tonani, Anuar Kilgore and Yannis Wang
Reacted by QuaOs, Makito Katsube, JhonSJ, Michael R., Nathan Tonani, Anuar Kilgore and Rajesh
Reacted by Alexandru Pavaloi, Morrisonleary, Getgud, Jae Young Lee, Chris, DendroDelinquent, Oli, shikharcognitve, Abhijit Sarkar, The Front Man and 112 more
Reacted by Naseer Rehman, Sufyan Motala, Ayaz Lockhat, Radik Ziiangirov, Zac Smith, SoleyDigital and Jack Theisen
Reacted by Cristian David Guzmán Tamayo, Leandro Arturi, Ozan Can Kösemez, lespuch-v, Adnan Mujagic, Pablo Suárez, Mantis_Prod, Rishabh Bahukhandi and Chan Jin
Reacted by shikharcognitve, Elesonchuang, gassims, Cavalcante, Lucas, Leandro Arturi, Michal Kulinski, lespuch-v, messagetoedward, Shreya Rathore, Adnan Mujagic and 13 more
Reacted by lespuch-v, Adnan Mujagic and Pablo Suárez
@Aninstance did you run yarn install or npm install after you changed package.json?
I'm using npm, however have multiple other resolutions in the list, which are installed running npx npm-force-resolutions. I run this after having run npm install (npm install does not correctly install the resolutions listed in package.json automatically).
Reacted by Sufyan Motala, Hasindu Lanka, Zac Smith, Her0Zer0, djay.cse, carsonxw, DaniAgb, Ahmed Khelifi, Andrea Grillo, Juan Sebastian Suarez Ramirez and 47 more
Reacted by Pavan, Muhammad Barjabin, gossarene, Santiago Quipildor, Calvin Donner, Steven Lopez, Sands and Jamim Mehdi
Reacted by Jonatas Santana souza, Andrea, Abhimanyu Malik, Sufyan Motala, Pavan, Jithin Jagadeesh, Muhammad Barjabin, gossarene, Santiago Quipildor, Steven Lopez and 3 more
Reacted by Renzo Castillo, Sufyan Motala, Vishwa Gaurav, Pavan, Muhammad Barjabin, Lorenzo Faivre, Santiago Quipildor, Steven Lopez and Jamim Mehdi
Absolutely solved it for now, thank you. (Was having a mental breakdown during)
Reacted by Matthew Davies, John Athanasiou, Sufyan Motala, Matias Ricarte, Murat Can Kırdar, Radhika Kakkar, aliu55, Eloi, Kathryn Jordan, Roni Litman and 1 more
Now it seems that it has already been fixed and this import looks like this: const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
Reacted by User12987, Tony Air, Blackays, ponasadomas, Terry, Pablo Enríquez Escamilla, chuchuching3545, akiLes, Paula Jiménez, Jose Chavez and 13 more
Reacted by Paula Jiménez, Jose Chavez, Tony Gentilcore, Patrik Toma and .Q Binh
Reacted by Monawwar Abdullah, Jose Chavez, Corentin Detry, Tony Gentilcore, ErikJRobles, .Q Binh and gary5wang
I'm actually still having this issue due to the fact that we're not saving lockfiles. It worked locally but when building on our CI server it was still broken.
There is no need to manually update package-lock.json, as long as you're on react-scripts v5 all you need to do is run npm update mini-css-extract-plugin
TypeError: MiniCssExtractPlugin is not a constructor
at module.exports (/home/john/Projects/test/node_modules/react-scripts/config/webpack.config.js:664:9)
at Object.<anonymous> (/home/john/Projects/test/node_modules/react-scripts/scripts/build.js:58:16)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47
Did you try recovering your dependencies?
Clearing package-lock.json and node_modules did not help at all.
└─▪ npm --version
8.3.0
Which terms did you search for in User Guide?
I have been searching for this error for a few hours but I can't find it anywhere. It shouldn't be happening on a fresh installation.
Environment
Environment Info:
current version of create-react-app: 5.0.0
running from /home/john/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app
System:
OS: Linux 5.15 Arch Linux
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Binaries:
Node: 14.18.2 - /usr/bin/node
Yarn: 1.22.17 - /usr/bin/yarn
npm: 8.3.0 - /usr/bin/npm
Browsers:
Chrome: Not Found
Firefox: 96.0
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 5.0.0 => 5.0.0
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
Issue can be replicated easily via
npx create-react-app test
cd test
npm run build
Expected behavior
I expected npm run build to work without errors.
Actual behavior
It produced the error TypeError: MiniCssExtractPlugin is not a constructor instead.
Reproducible demo
git clone https://github.com/jathanasiou/react-mincss-crash.git
cd react-mincss-crash
npm i && npm run build
Activity
cgibsonmm commentedon Jan 14, 2022
Same Failing fresh install Build fails
Morrisonleary commentedon Jan 14, 2022
Same, getting the same errors. I have changed my nvm to 16 and even lower than that, tried yarn, cleared out the cache, etc.
iampava commentedon Jan 14, 2022
I think it's because of an update to
mini-css-extract-pluginwhich was bumped 4 hours ago to version2.5.0. I temporarily fixed it by adding:in
package.json.ConsciousUniverse commentedon Jan 14, 2022
I tried that, to no avail; the same issue persists.
iampava commentedon Jan 14, 2022
@Aninstance did you run
yarn installornpm installafter you changedpackage.json?oBusk commentedon Jan 14, 2022
resolutionsisyarnfeature. If you're not usingyarn, you can either runor if you're using
npm@>=8.3.0, addoverridesto your
package.json, and runnpm iConsciousUniverse commentedon Jan 14, 2022
I'm using npm, however have multiple other resolutions in the list, which are installed running
npx npm-force-resolutions. I run this after having runnpm install(npm install does not correctly install the resolutions listed in package.json automatically).daviesgeek commentedon Jan 14, 2022
Pinning the mini css extract version worked for me:
Edit:
It does seem like adding
resolutionsto the package.json works as well:berenteb commentedon Jan 14, 2022
Absolutely solved it for now, thank you. (Was having a mental breakdown during)
daniil-loban commentedon Jan 14, 2022
I changed import in
node_modules/react-scripts/config/webpack.config.jsconst { default: MiniCssExtractPlugin } = require('mini-css-extract-plugin');UPDATE (27 Jan 2022):
Now it seems that it has already been fixed and this import looks like this:
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');daviesgeek commentedon Jan 14, 2022
I'm actually still having this issue due to the fact that we're not saving lockfiles. It worked locally but when building on our CI server it was still broken.
Fix issue react#11930 where mini css extract plugin was updated to ne…
83 remaining items
Fix build
temporal-fix: react/create-react-app#11930
quocbinh-npm9081 commentedon Jan 19, 2022
It worked, thank iu <3
Downgrade CRA from 5 to 4
Fix mini-css-extract-plugin version
tom-sherman commentedon Jan 21, 2022
There is no need to manually update package-lock.json, as long as you're on react-scripts v5 all you need to do is run
npm update mini-css-extract-pluginResolve TypeError: MiniCssExtractPlugin is not a constructor" in a bu…
robFraser1111 commentedon Jan 26, 2022
For me I just needed to install mini-css-extract-plugin to get the build working.
npm update
fixes react/create-react-app#11930
build: fix build plugin type error
adding a resolution for mini-css-extract-plugin, refer to react/creat…
fix react/create-react-app/issues/11930
Limpisey168 commentedon Apr 2, 2022
console.log
fix: install `mini-css-extract-plugin` to fix bug when build