question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"TypeError: MiniCssExtractPlugin is not a constructor" in fresh CRA installation

See original GitHub issue

Describe the bug

CRA build fails with

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:104
  • Comments:66

github_iconTop GitHub Comments

167reactions
oBuskcommented, Jan 14, 2022

I think it’s because of an update to mini-css-extract-plugin which was bumped 4 hours ago to version 2.5.0. I temporarily fixed it by adding:

  "resolutions": {
    "mini-css-extract-plugin": "2.4.5"
  },

in package.json.

resolutions is yarn feature. If you’re not using yarn, you can either run

npm i -D --save-exact mini-css-extract-plugin@2.4.5

or if you’re using npm@>=8.3.0, add overrides

  "overrides": {
    "mini-css-extract-plugin": "2.4.5"
  }

to your package.json, and run npm i

111reactions
iampavacommented, Jan 14, 2022

I think it’s because of an update to mini-css-extract-plugin which was bumped 4 hours ago to version 2.5.0. I temporarily fixed it by adding:

  "resolutions": {
    "mini-css-extract-plugin": "2.4.5"
  },

in package.json.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: MiniCssExtractPlugin is not a constructor
I have got this error and don't understand why it happens. I didn't change any package version and have just done npm install...
Read more >
`npm run build`, error `TypeError: MiniCssExtractPlugin is not ...
There is an update to mini-css-extract-plugin in version 2.5.0. I temporarily fixed it by adding in ... TypeError: MiniCssExtractPlugin is not a constructor...
Read more >
React の build で MiniCssExtractPlugin is not a constructor と ...
"TypeError: MiniCssExtractPlugin is not a constructor" in fresh CRA installation #11930. 原因は、ここに書いてある通り、 ...
Read more >
TypeError: MiniCssExtractPlugin is not a constructor - Drupal
TypeError : MiniCssExtractPlugin is not a constructor. Closed (fixed). Project: Bootstrap Italia. Version: 8.x-0.20. Component:.
Read more >
Clone of playsnake.org using React and TypeScript
React swipe event handler hook · Swipe effect in react js · “TypeError: MiniCssExtractPlugin is not a constructor” in fresh CRA installation ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found