[英]Uncaught ReferenceError with redux-saga
我正在尝试使用 redux-saga 模块。
但是我有以下错误。
Uncaught ReferenceError: regeneratorRuntime is not defined
at eval (saga.js:5)
at Object../js/sagas/saga.js (saga.js:393)
at __webpack_require__ (saga.js:20)
at eval (configureStore.js:8)
at Object../js/stores/configureStore.js
saga.js
很简单。
export function* helloSaga(){
console.log('Hello Sagas!');
}
我已经安装了以下模块。
npm install @babel/polyfill --save
发生了什么?
检查你的 babel 配置。
对于@babel/preset-env 检查exclude
和useBuiltIns
选项: https : useBuiltIns
对于 @babel/preset-transform-runtime 检查regenerator
选项:
https://babeljs.io/docs/en/babel-plugin-transform-runtime#regenerator
此外,@babel/polyfill 已被弃用,转而支持在 babel 7.4 中直接使用 core-js 和 regenerator-runtime/runtime:
https://babeljs.io/blog/2019/03/19/7.4.0#migration-from-core-js-2
https://babeljs.io/docs/en/babel-polyfill
最后,尝试在 babel-loader 中明确设置 .babelrc 的路径。 我有一个理论,即 babel 使用不同的.babelrc
名称默认值来解析它的某些任务。
https://babeljs.io/docs/en/options#configfile或
https://babeljs.io/docs/en/options#extends
最后我可以使用@babel/polyfill
即使它是重复的。
npm install @babel/polyfill --save
import '@babel/polyfill';
export function* helloSaga(){
console.log('Hello Sagas!');
}
错误不出来。 有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.