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.

`npm run build` fails to compile on a fresh unmodified CRA app ("Class constructor Parser cannot be invoked without 'new'")

See original GitHub issue

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':

Screen Shot 2020-09-16 at 15 53 24

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

  1. npx create-react-app foo
  2. cd foo/
  3. 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

Screen Shot 2020-09-16 at 15 53 24 (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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:28
  • Comments:24 (1 by maintainers)

github_iconTop GitHub Comments

23reactions
maxabramscommented, Sep 17, 2020

+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).

20reactions
aicommented, Sep 17, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Class constructor Parser cannot be invoked without 'new'" in ...
... App by "npm run build". But the same application works with "npm start". Error: Class constructor Parser cannot be invoked without 'new'....
Read more >
Deployment | Create React App
Sometimes npm run build works locally but fails during deploy via Heroku. Following are the most common cases. "Module not found: Error: Cannot...
Read more >
Pagination in grid for production build has error "Class ...
Forum Thread - Pagination in grid for production build has error "Class constructor e cannot be invoked without 'new'" - Angular - EJ...
Read more >
[Support Guide] Frequently encountered problems during builds
In case your build fails on Netlify, first make sure it builds locally in ... Unfortunately, the error messages that result may not...
Read more >
Cannot Build | Quasar Framework Community
... processing TypeError: Class constructor Parser cannot be invoked without 'new' - safe-parser.js:17 new SafeParser [spotify-saas-www]/[p.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

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