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.

Build error when using react-scripts

See original GitHub issue

I’ve ran into a build issue when using this in a project created with create-react-project.

# npm run build
> react-scripts build  

Creating an optimized production build...
Failed to compile.

TypeError: C:\Users\Sam\WebstormProjects\untitled1\node_modules\@floating-ui\core\dist\floating-ui.core.browser.min.mjs: Cannot read properties of undefined (reading 'constantViolations')
    at transformFile.next (<anonymous>)
    at run.next (<anonymous>)
    at transform.next (<anonymous>)

The same error doesn’t occour if I repoint it to use the non-minified mjs file.

Reproduction steps (node 18 or 16)

  1. start new project npx create-react-app test-bug
  2. install the react-dom package npm install @floating-ui/react-dom
  3. update src/App.js to reference package (example below)
  4. do npm run build
import {useFloating} from "@floating-ui/react-dom";
import './App.css';

function App() {
  const {x, y, reference, floating, strategy} = useFloating();

  return (
      <>
        <button ref={reference}>Button</button>
        <div
            ref={floating}
            style={{
              position: strategy,
              top: y ?? 0,
              left: x ?? 0,
              width: 'max-content',
            }}
        >
          Tooltip
        </div>
      </>
  );
}
export default App;

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
atomikscommented, Dec 22, 2022

There may be a bit of a delay in releasing this fix (will be within the next ~1 week though), so in the meantime anyone encountering this issue, install patch-package and edit node_modules/@floating-ui/core/package.json by removing the min from the "browser" default field (so it uses the unminified file, it’ll still get minified). This will make your builds work until the patch gets released.

1reaction
atomikscommented, Dec 22, 2022

Oof yeah… I think they should revert that rewrite they did for now or something and do more testing against it

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-scripts fails to build project with Node 17 #11562 - GitHub
Describe the bug we have a CRA app, it used to build with Node 14.x very fine, today I upgrade nodejs to 17.0.0...
Read more >
react-scripts build error code-134, not creating build
I got my issue resolve by adding below one line of code in package.json "scripts" section. "scripts": {"build": "react-scripts --expose-gc ...
Read more >
How to fix build failures with `create-react-app` in production
The build script bootstrapped by create-react-app performs some validation of your code. When most of this validation fails, create-react-app ...
Read more >
Fixing 'react-scripts' is not recognized error - Nathan Sebhastian
To fix this kind of error, first check on your package.json file and see if react-scripts is listed as one of the dependencies...
Read more >
react-scripts: command not found error [Solved] | bobbyhadz
Run the `npm install react-scripts` command to solve the react-scripts: command not found error. If necessary delete your `node_modules` directory and your ...
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