react-slider icon indicating copy to clipboard operation
react-slider copied to clipboard

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

Open dognose24 opened this issue 1 year ago • 5 comments

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

dognose24 avatar Jun 21 '23 02:06 dognose24

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.

anomiex avatar Jun 21 '23 18:06 anomiex

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.

msf-caesar avatar Sep 01 '23 04:09 msf-caesar

@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.

anomiex avatar Sep 09 '23 14:09 anomiex

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?

ajrussellaudio avatar Dec 19 '23 20:12 ajrussellaudio

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.

samparmenter avatar Jun 20 '24 13:06 samparmenter