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

"Cannot resolve module babel-runtime/regenerator" #255

Closed
gaearon opened this issue Jul 28, 2016 · 18 comments
Closed

"Cannot resolve module babel-runtime/regenerator" #255

gaearon opened this issue Jul 28, 2016 · 18 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Jul 28, 2016

I get this message when I use generators because babel-runtime is not a runtime dependency of the generated project. I didn’t notice this when I merged #238 because I tested only the local flow (npm run create-react-app).

I see three possible solutions:

  • Document this as a known gotcha in the howto. (People using generators would probably find it quick enough.)
  • Put babel-runtime into everyone’s dependencies on project creation regardless of whether they actually use generators. (Not very good, we have no control over the version, and this exposes Babel to users which we’d rather avoid.)
  • Add an option to babel-plugin-transform-runtime that would let us set runtimeModuleName to a resolved path. (I would prefer this.)
@k-dahl
Copy link

k-dahl commented Jul 28, 2016

I just ran into something similar when using react-input-enhancements, adding babel-runtime fixed the issue. Just importing anything from the lib would cause a compile failure.

@insin
Copy link
Contributor

insin commented Jul 28, 2016

You could try using resolve.fallback config to make babel-runtime resolvable.

@gaearon
Copy link
Contributor Author

gaearon commented Jul 28, 2016

You could try using resolve.fallback config to make babel-runtime resolvable.

This works as an interim solution but I don’t like that it makes us more tied to Webpack resolution mechanism. I would we solve this in a more generic way.

@taion
Copy link

taion commented Jul 28, 2016

You can solve this by bundling up all the polyfill-style dependencies (including the current promise and whatwg-fetch) into a single runtime dependency, then hiding Babel under there.

You have the same "exposes users" and "version control" issues with the current polyfill dependencies anyway.

@gaearon
Copy link
Contributor Author

gaearon commented Jul 28, 2016

Not sure I fully understand what you propose, can you elaborate?
I currently only want babel-runtime for regenerator, I don’t need it for any other use cases.

@taion
Copy link

taion commented Jul 28, 2016

@gaearon Never mind – I just realized this is really another thing like #247 where the problem is that babel-runtime doesn't end up at top-level in node_modules.

@gaearon
Copy link
Contributor Author

gaearon commented Jul 28, 2016

I’ll plug the hole for now with #262 but this is suboptimal (e.g. probably won’t work with Jest).
Will revisit as soon as we find a case that doesn’t work well with that hack.
I hope that babel/babel#3612 lets us do this, but if not, we’ll probably have to add babel-runtime for everyone at some point.

gaearon added a commit that referenced this issue Jul 28, 2016
This enables us to ship them now, and find a way to resolve runtime path without webpack later.
See #255
gaearon added a commit that referenced this issue Jul 28, 2016
This enables us to ship them now, and find a way to resolve runtime path without webpack later.
See #255
@taion
Copy link

taion commented Jul 29, 2016

Can this also be resolved by not shipping babel-runtime as a bundled dependency? Possibly ESLint as well. Then they'd just end up at top-level in node_modules.

@taion
Copy link

taion commented Jul 29, 2016

I'm not saying "drop bundledDependencies", just "un-bundle stuff that's expected to be at top-level in node_modules".

@gaearon
Copy link
Contributor Author

gaearon commented Jul 29, 2016

So that’s why they end up there even with npm 3, you’re right.
I didn’t realize that.

@gaearon
Copy link
Contributor Author

gaearon commented Jul 29, 2016

A PR to unbundle ESLint plugins and babel-runtime is welcome. We’d probably want to keep the rest bundled though.

@taion
Copy link

taion commented Jul 29, 2016

Ah, this won't work – at least, it won't work in a straightforward way. It looks like babel-runtime still ends up as a nested dependency, because the other bundled Babel dependencies pull in babel-runtime... I think.

Well, anyway it worked for the ESLint plugins, but not babel-runtime, so that's my best guess.

And npm ddp after an install takes forever, so that's out too.

@taion
Copy link

taion commented Jul 29, 2016

Though – anybody else looking at this, don't take that as gospel. Very likely I just messed up.

@mpj
Copy link

mpj commented Aug 11, 2016

For anyone googling this error when trying to run Jest tests on generators (as @gaearon pointed out it the fix in #262 does not seem to work in Jest), looking for the workaround:

I fixed this by putting babel-runtime in my app dependencies. This fixed the issue.
Is this a recommended way to work around this for now?

@gaearon gaearon added this to the 0.3.0 milestone Aug 25, 2016
@hzoo
Copy link

hzoo commented Sep 1, 2016

babel/babel#3612 is released in v6.15.0 of babel-plugin-transform-runtime

npm view babel-plugin-transform-runtime dist-tags

gaearon added a commit that referenced this issue Sep 1, 2016
This makes generators work with Jest.

Fixes #255.
Replaces #262.
gaearon added a commit that referenced this issue Sep 1, 2016
This makes generators work with Jest.

Fixes #255.
Replaces #262.
stayradiated pushed a commit to stayradiated/create-react-app that referenced this issue Sep 7, 2016
This makes generators work with Jest.

Fixes facebook#255.
Replaces facebook#262.
feiqitian pushed a commit to feiqitian/create-react-app that referenced this issue Oct 25, 2016
This makes generators work with Jest.

Fixes facebook#255.
Replaces facebook#262.
@scholtzm
Copy link
Contributor

Sorry for bumping old issue here...

Recently, out of nowhere, I started having issues with missing babel-runtime:

Adding babel-runtime to my dependencies fixes this issue but I'm not sure if this is the right way to go about it?

@gaearon
Copy link
Contributor Author

gaearon commented Jan 18, 2017

Please file a new issue with details.

@scholtzm
Copy link
Contributor

Move to #1421

@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants