Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dognose24 opened this issue Jun 21, 2023 · 5 comments

Comments

@dognose24
Copy link

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 #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
Copy link

anomiex commented Jun 21, 2023

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
Copy link

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
Copy link

anomiex commented Sep 9, 2023

@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
Copy link

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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants