Skip to content
This repository has been archived by the owner on Aug 7, 2021. It is now read-only.

@babel/runtime should be listed as a dependency instead of babel-runtime #182

Open
kengorab opened this issue Jul 16, 2020 · 0 comments · May be fixed by #258
Open

@babel/runtime should be listed as a dependency instead of babel-runtime #182

kengorab opened this issue Jul 16, 2020 · 0 comments · May be fixed by #258

Comments

@kengorab
Copy link

The Bug

When looking at the compiled code which is included at runtime ([email protected]), there are calls to import files under the @babel/runtime package, eg.

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

This throws an error at runtime, since it's not guaranteed that the @babel/runtime dependency is installed.

Steps to Reproduce

You can reproduce this with a super minimal example:

mkdir bug-repro && cd !$
npm init -y
npm i react react-dom react-scrollspy
node -e "require('react-scrollspy')"

The output of which will be:

node -e "require('react-scrollspy')"
internal/modules/cjs/loader.js:969
  throw err;
  ^

Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'
Require stack:
- /Users/kengorab/code/bug-repro/node_modules/react-scrollspy/lib/scrollspy.js
- /Users/kengorab/code/bug-repro/[eval]
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/kengorab/code/bug-repro/node_modules/react-scrollspy/lib/scrollspy.js:3:30)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/kengorab/code/bug-repro/node_modules/react-scrollspy/lib/scrollspy.js',
    '/Users/kengorab/code/bug-repro/[eval]'
  ]
}

Potential Solution

A workaround for this would just be to explicitly depend on @babel/runtime, but this package should include it in its dependencies so npm/yarn can resolve it correctly. It appears this has a dependency on babel-runtime, which could probably just be changed to @babel/runtime to resolve this issue.

Note this might not be an issue in newer projects which were built with create-react-app, as react-scripts pulls in @babel/runtime.

schmave added a commit to schmave/react-scrollspy that referenced this issue Jun 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant