Npm Dependency is Breaking Some React Apps Today — here’s the Fix

Npm Dependency is Breaking Some React Apps Today — here’s the Fix

Tons of users are reporting their Facebook Create React App builds are failing since yesterday.

The cause has been traced down to a dependency used by create-react-app, the latest version of which is breaking developers’ apps.

While a stable solution is yet to be identified, here’s a simple workaround developers can adopt.

create-react-app builds failing worldwide

Create React App is an open source project produced by Facebook (Meta) and made available on both GitHub and npm to help developers build single-page React applications fast.

The GitHub project is used by over 5.4 million repositories, whereas the npm version receives around 200,000 weekly downloads on average.

The tool offers a modern build setup while requiring no complex configuration—developers can therefore build a React app with just a few simple commands.

That explains why so many developers would rely on create-react-app and are experiencing build failure issues since yesterday.

Software engineer John Athanasiou and front-end developer Ronald Groot Jebbink have been joined by many GitHub users who reported problems building their create-react-app builds into today.    

Also Read: How does Do Not Call (DNC Registry) Affect Marketing 2020

Users report their create-react-app builds failing (GitHub)

Dependency hell strikes again

The straightforward error message “TypeError: MiniCssExtractPlugin is not a constructor,” gives it away.

The problem has been traced down to one of the dependencies, called mini-css-extract-plugin, used by create-react-app.

Mini CSS Extract Plugin is yet another popular project with over 4.6 million GitHub repos relying on it.

With over 7,000 npm projects depending on Mini CSS Extract Plugin, the project receives 10 million weekly downloads on average on the npm registry.

Mini CSS Extract Plugin came to life in 2018, around the same time as Extract Text Webpack Plugin was deprecated by its author.

This project extracts CSS into separate files, generating a CSS file per JS file that contains CSS.

The latest version of Mini CSS Extract Plugin, 2.5.0 was published less than a day ago and appears to be the culprit. It is since the publication of this particular version that create-react-app project builds began to fail.

Interestingly, as seen by BleepingComputer, the changelog for version 2.5.0 has the maintainer noting a new feature addition, “types” having been made: 

Version 2.5.0 of Mini CSS Extract Plugin comes with “added types” (GitHub)

And we wonder if the particular commit is what’s impacting create-react-app instances to break.

bug report filed for the Mini CSS Extract Plugin’s maintainers to look at goes over some possible causes. 

Also Read: Free Privacy Policy Compliance Review

Until a concrete fix is identified by Facebook’s open source team, devs have noted success by downgrading their version of the mini-css-extract-plugin to 2.4.5:

This can be done by updating your JavaScript app’s package.json file to include the following lines,  thereby pinning the dependency’s version to 2.4.5, as proposed by developer Alexandru Pavaloi:

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

Those who are not using yarn, and for whom the above workaround fails can try running the following command, as suggested by front-end developer Oscar Busk:

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

“I tried everything ‘resolutions’ as well as ‘overrides’ but none of these worked until I tried the one above!” writes a user.

Note, Facebook’s Create React App may not be the only prominent application to be impacted by the new dependency version.

Npm project @wordpress/scripts is also reportedly breaking.

Also Read: The Importance of Penetration Testing for Businesses

Developers of Auth0’s SDK for single-page applications are temporarily locking in the dependency version to ‘2.4.5’ to be safe.

Although not malicious in nature, this incident follows last week’s news of popular ‘colors’ and ‘faker’ npm dependencies breaking thousands of software projects after their developer had corrupted them.

BleepingComputer has reached out to Facebook (Meta) to better understand the cause of the issue. In the meantime, we hope the above workarounds will save your React builds.

Privacy Ninja

Recent Posts

Role of Enhanced Access Controls in Safeguarding Personal Data in Telecommunications

Role of Enhanced Access Controls in Safeguarding Personal Data in Telecommunications that every Organisation in…

2 weeks ago

Role of Effective Incident Response Procedures in Strengthening Data Security

Effective Incident Response Procedures in Strengthening Data Security that every Organisation in Singapore should know…

2 weeks ago

Strengthening Your Cyber Defenses: The Crucial Role of Regular Vulnerability Scanning

Crucial Role of Regular Vulnerability Scanning that every Organisation in Singapore should know. Strengthening Your…

2 weeks ago

Enhancing Data Security with Multi-Factor Authentication

Enhancing Data Security with Multi-Factor Authentication that every Organisation in Singapore should know. Enhancing Data…

3 weeks ago

A Strong Password Policy: Your Organization’s First Line of Defense Against Data Breaches

Strong Password Policy as a first line of defense against data breaches for Organisations in…

3 weeks ago

Enhancing Website Security: The Importance of Efficient Access Controls

Importance of Efficient Access Controls that every Organisation in Singapore should take note of. Enhancing…

4 weeks ago