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

[Bug]: @babel/runtime v7.18.0 cause a runtime "regeneratorRuntime is not defined" error #14576

Closed
1 task
tinder1024 opened this issue May 23, 2022 · 19 comments · Fixed by #14581
Closed
1 task
Labels
area: downstream i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@tinder1024
Copy link

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

placehoder

Configuration file name

No response

Configuration

No response

Current and expected behavior

I thought the problem might be
image

Environment

@babel/runtime version 7.18.0

Possible solution

No response

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @tinder1024! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented May 23, 2022

Is the error coming from your code or from a dependency? Which is the full stack trace?

The helpers/regeneratorRuntime file you are not seeing is generated at build time and it is included in the released version (you can check in your node_modules).

@cuitianze
Copy link

same issue

@IanTorquato
Copy link

IanTorquato commented May 23, 2022

I "found" the solution

Or rather, the comment about this issue ahsuahush

I solved it by forcing the version in package.json/resolutions

"resolutions": {
    "@babel/runtime": "7.18.0"
  },

@nicolo-ribaudo
Copy link
Member

This is a bug with some other packages that has a dependency on regenerator-runtime but doesn't specify it in their package.json. They were lucky because it was a dependency of @babel/runtime so it was still loaded, but in Babel 7.18.0 it doesn't happen anymore.

Please, always share your stacktraces so that we can report this to the buggy packages!

@cuitianze
Copy link

[CompileProject][INFO] Error: [vite]: Rollup failed to resolve import "@babel/runtime/helpers/esm/regeneratorRuntime" from "node_modules/@ant-design/pro-card/node_modules/@ant-design/pro-utils/es/hooks/useDebounceFn/index.js".

@yerlink
Copy link

yerlink commented May 24, 2022

lock the old dependency version:
"@babel/runtime": "7.17.2",
"@babel/plugin-transform-runtime": "7.17.0",

@nicolo-ribaudo
Copy link
Member

Note

The regeneratorRuntime is not defined errors are different from the error about @babel/runtime/helpers/esm/regeneratorRuntime. The ant-design maintainers are already aware of the second one.

@drbeat
Copy link

drbeat commented May 24, 2022

I "found" the solution

Or rather, the comment about this issue ahsuahush

I solved it by forcing the version in package.json/resolutions

"resolutions": {
    "@babel/runtime": "7.18.0"
  },

none of the suggested solutions in the comment works for us
we bundle a react library with rollup, not sure how to work around this issue which came out of nowhere...
_node_modules_babel_preset_react_app_node_modules_babel_runtime_helpers_esm_regeneratorRuntime_js__WEBPACK_IMPORTED_MODULE_0__.default)(...).exports is not a function

@nicolo-ribaudo
Copy link
Member

@drbeat Can you share a gist containing your lockfile?

@drbeat
Copy link

drbeat commented May 24, 2022

So after setting @babel/preset-react in resolutions it works now.
"resolutions": { "@babel/preset-react": "7.17.12" },

@yyyeyao
Copy link

yyyeyao commented May 24, 2022

Solved by replacing @babel/runtime": "^7.16.3" with @babel/runtime": "7.16.3"

@markwoon
Copy link

This is a bug with some other packages that has a dependency on regenerator-runtime but doesn't specify it in their package.json. They were lucky because it was a dependency of @babel/runtime so it was still loaded, but in Babel 7.18.0 it doesn't happen anymore.

This implies that if I add regenerator-runtime myself, things should work again, but that's not the case.

I'm declaring this dependency and still get the error.

In my case, the stacktrace is:

    at eval (react-table.development.js?9781:272:1)
    at useAsyncDebounce (react-table.development.js?9781:350:6)
    at TextFilter (Text.js?0cad:62:54)
    at renderWithHooks (react-dom.development.js?f8c1:16175:1)
    at mountIndeterminateComponent (react-dom.development.js?f8c1:20913:1)
    at beginWork (react-dom.development.js?f8c1:22416:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js?f8c1:4161:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js?f8c1:4210:1)
    at invokeGuardedCallback (react-dom.development.js?f8c1:4274:1)
    at beginWork$1 (react-dom.development.js?f8c1:27405:1)```

@nicolo-ribaudo
Copy link
Member

You also have to import that library in your code, since it's side-effectful.

@nicolo-ribaudo
Copy link
Member

I opened #14581 to make this error more rare. However, please continue reporting this bug to the affected libraries so that they can fix it.

@daejong123
Copy link

same issue in vue-cli with @vue/cli-plugin-babel.
image

@mansion-sun
Copy link

mansion-sun commented May 27, 2022

babel版本的问题,我删除旧的依赖,重新安装解决了这个问题;虽然我的两个项目使用了不同方式来处理,但是最终生效都是babel/runtime版本更新到7.18.3!

@taylordlankford
Copy link

error Generating JavaScript bundles failed
10:14:10 AM: Can't resolve '@babel/runtime/helpers/esm/regeneratorRuntime' in '/opt/build/repo/node_modules/rc-util/es/React'
10:14:10 AM: If you're trying to use a package make sure that '@babel/runtime/helpers/esm/regeneratorRuntime' is installed. If you're trying to use a local file make sure that the path is correct.

@nicolo-ribaudo
Copy link
Member

Update rc-util.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Sep 8, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: downstream i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.