create-react-app: `npm run build` fails to compile on a fresh unmodified CRA app ("Class constructor Parser cannot be invoked without 'new'")
Describe the bug
Completely fresh and unmodified create-react-app app fails to build with npm run build
. Error is Class constructor Parser cannot be invoked without 'new'
:
Did you try recovering your dependencies?
Probably N/A since completely fresh, unmodified output of initial npx create-react-app...
command, but yep, I did try. Did not help.
Which terms did you search for in User Guide?
Had a glance through the build section again, searched Google, and searched issues here for the specific error.
Environment
current version of create-react-app: 3.4.1
running from /Users/janabeck/.npm/_npx/50873/lib/node_modules/create-react-app
System:
OS: macOS 10.15.6
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 12.18.3 - /var/folders/pq/gd8qpx2s5b95t3jnvrrx0nh40000gq/T/fnm-shell-2477482/bin/node
Yarn: Not Found
npm: 6.14.8 - /var/folders/pq/gd8qpx2s5b95t3jnvrrx0nh40000gq/T/fnm-shell-2477482/bin/npm
Browsers:
Chrome: 85.0.4183.102
Firefox: Not Found
Safari: 13.1.2
npmPackages:
react: Not Found
react-dom: Not Found
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found
And my coworker’s, who verified the failure:
Environment Info:
current version of create-react-app: 3.4.1
running from /Users/robertharris/.npm/_npx/92901/lib/node_modules/create-react-app
System:
OS: macOS 10.15.6
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 14.9.0 - /usr/local/bin/node
Yarn: Not Found
npm: 6.14.7 - /usr/local/bin/npm
Browsers:
Chrome: 85.0.4183.102
Firefox: Not Found
Safari: 13.1.2
npmPackages:
react: ^16.13.1 => 16.13.1
react-dom: ^16.13.1 => 16.13.1
react-scripts: 3.4.3 => 3.4.3
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
npx create-react-app foo
cd foo/
npm run build
I also tried npx create-react-app@3.3.1...
to see if going back one minor version would change anything, but the result was the same.
Expected behavior
A fresh unmodified CRA app should build successfully.
Actual behavior
(Same screenshot as above.)Reproducible demo
Pushed my fresh unmodified CRA app here: https://github.com/jebeck/cra-build-failure
So just clone, npm i
, and npm run build
. I have also tested on a 3rd machine (in addition to mine and my coworker’s) and I get the same failure.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 28
- Comments: 24 (1 by maintainers)
Commits related to this issue
- updates postcss version due to https://github.com/facebook/create-react-app/issues/9655 — committed to uclaacm/teach-la-react-starter-barebones by mattxwang 4 years ago
- Upgrade to fix build issue Ref: https://github.com/facebook/create-react-app/issues/9655 — committed to codexico/marvel-test-create-react-app by deleted user 4 years ago
+1. Has been working all day and recently (within the hour) began failing. Targeting specific, previous versions in package.json has no impact. We cannot build any React projects (new or existing).
The fix was released in PostCSS 7.0.34.
If you want t say thanks for the quick night fix, our PostCSS Open Collective will be the best option
add “postcss”: “7.0.32” to your package.json
I think I found the problem. I had the same issue even though the project has ejected from CRA long ago. (Project doesn’t have lock file) It might be a problem of postcss@7.0.33 and if I changes yarn.lock (postcss@7.0.33 to postcss@7.0.32), build runs successfully.
I’ve been running create-react app all day and just got this issue within the last couple hours. Odd, I noticed on the Github releases tab the latest stable is 3.4.1: https://github.com/facebook/create-react-app/releases
While on NPM there is a 3.4.2 and 3.4.3 release - Github doesn’t seem area of this…
@davidboschwitz the last commit from about 1hr ago (when CRA broke for me) is related to postcss - but it should only touch the 4.x release
Maybe something got bumped and released to npm on a local dev machine ? 🙈
Should be good with the fix @ai provided. My fix should no longer be needed.
This was cool to see the development community investigate and resolve a pipeline blocking issue in under 3 hours. Thanks everyone for you help and contributions!
Thanks @pasdoy - the issue is under review https://github.com/postcss/postcss/issues/1412 but this works if you have access to the command line.
I just did a fresh new CRA again, and it appears everything has been fixed upstream? I didn’t have to modify the output at all; no install of postcss or anything. Maybe I’ll wait a bit for additional confirmation, but otherwise feels like I can close this issue. Echoing @NiyongaboEric, thank you all for helping to get this resolved so quickly! 🎉
I can’t sign the CLA due to a non-compete agreement with my employer. The necessary changes are in https://github.com/facebook/create-react-app/pull/9658 if someone else wants to do the change, and submit a pull request that is not on my behalf or that of my employer.
Another one here, of course it happens when experimenting with something new. Thought I was the only one with this error.
If you still have any device/build environment that has an unaffected node modules cache: As a temporary workaround (hack) we are manually copying a cached version of node_modules and neglecting to run
npm install
to circumvent the upstream dependency changes.Thank you @ai & @jebeck @erikig & everyone who contributed. I solved the issue by installing
npm i postcss
. My CRA is not ejected and whenever I build the appnpm run build
, It works expectedly. Thanks for collaboration to fix the bugs.I can confirm after testing locally & in our project ci’s that the issue has been resolved with the release of PostCSS 7.0.34, our pipelines have been restored! Thank @ai for the fix.
+1. Likewise. Targeting CRA 3.4.* or 3.3.* doesn’t resolve the issue.
npm start
seems to work ok.