zillow / react-slider

Accessible, CSS agnostic, slider component for React.
https://zillow.github.io/react-slider
MIT License
883 stars 231 forks source link

Module not found: Error: Can't resolve '@babel/runtime/helpers/inheritsLoose' #296

Open dognose24 opened 1 year ago

dognose24 commented 1 year ago

Description

ReactSlider attempts to use @babel/runtime from dist/es/prod/components/ReactSlider/ReactSlider.mjs but does not declare a dependency or peer dependency. This issue would be similar to https://github.com/zillow/react-slider/issues/284.

This happens to work with npm's hoisting due to other dependencies pulling that package in, but it will fail with yarn's p'n'p or pnpm with hoisting disabled.

CodeSandbox

Unfortunately, we can not provide the sandbox for reproducing the issue, but our projects have ongoing PR running checks for building with the component usages.

截圖 2023-06-21 上午10 13 34
anomiex commented 1 year ago

To see the problem from a command line:

With yarn:

  1. Create a temporary directory, and cd into it.
  2. echo '{}' > package.json
  3. yarn set version stable
  4. yarn add react-slider react react-dom
    • Note yarn gives no complaints about missing peer dependencies.
  5. yarn node -e 'require( "react-slider" );'

With pnpm:

  1. Create a temporary directory, and cd into it.
  2. echo 'hoist-pattern=[]' > .npmrc
  3. pnpm add react-slider
    • Note pnpm 8 defaults to auto-installing all declared peer dependencies.
  4. node -e 'require( "react-slider" );'

If you want something more like a sample repo, test.zip should suffice. See the included readme for instructions.

msf-caesar commented 10 months ago

Try with reinstalling the @babel/runtime package and ensuring that it is declared as a dependency or peer dependency in the project's package.json file. If that doesn't resolve the issue, check if there are any conflicting dependencies that may be causing the problem.

anomiex commented 9 months ago

@msf-caesar You seem to have misunderstood the issue here. You may want to experiment with the test.zip I attached to my earlier comment. Be sure to read the included readme file, particularly the final sentence.

ajrussellaudio commented 6 months ago

Same error for me, using NextJS with NPM, and TypeScript but no Babel.

Installing @babel/runtime as a devDependency did not fix the issue. But I agree with @anomiex on this point from their readme:

Please don't claim a "fix" is to add dependencies to the root package.json, that would be cheating.

I'm not using Babel elsewhere in the project. If it's a (peer) dependency of react-slider then could it be declared as such?

samparmenter commented 1 week ago

Yeah, I have no idea why its not declared as a dependency when...its a dependency. I assume most people have this installed via another packages dependency tree so it never pops up as an error but it should be in react-sliders dependences.