gpt4 book ai didi

reactjs - regeneratorRuntime 未定义 rete.js

转载 作者:行者123 更新时间:2023-12-03 14:22:45 27 4
gpt4 key购买 nike

好吧,我能够找到解决我的问题的方法。我正在尝试将 Next.js 中的 Rete.js 与 Typescript 一起使用。我看到以下错误:

regeneratorRuntime is not defined

这是我的配置

package.json

"dependencies": {
"@types/next": "^9.0.0",
"@types/react": "^16.9.19",
"next": "^9.2.1",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"rete": "^1.4.3-rc.1",
"rete-area-plugin": "^0.2.1",
"rete-connection-plugin": "^0.9.0",
"rete-dock-plugin": "^0.2.1",
"rete-react-render-plugin": "^0.2.0"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.8.3",
"@types/node": "^13.7.1",
"typescript": "^3.7.5"
}
}

tsconfig.json

{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"jsx": "preserve",
"lib": [
"dom",
"es2017"
],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"preserveConstEnums": true,
"removeComments": false,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"target": "esnext",
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"isolatedModules": true
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
]
}

.babelrc

{
"presets": ["next/babel"],
"plugins": [
[
"@babel/plugin-transform-runtime",
{
"absoluteRuntime": false,
"corejs": false,
"helpers": true,
"regenerator": true,
"useESModules": false,
"version": "7.0.0-beta.0"
}
]
]
}

我还尝试安装 core-jsregenerator-runtime 并尝试如下:

import "core-js/stable";
import "regenerator-runtime/runtime";

但对我来说没有任何作用。您能提出一些可以解决我的问题的建议吗?

最佳答案

无需安装core-jsregenerator-runtime@babel/plugin-transform-runtime 提供所需的运行时。我只是缺少一个基本的东西,没有添加@babel/preset-env。我以为 next/babel 包含 .babelrc 文件所需的所有内容,但事实并非如此。这是对我有用的最终 .babelrc 文件。

{
"presets": [
"@babel/preset-env",
"next/babel"
],
"plugins": [
["@babel/plugin-transform-runtime"]
]
}

关于reactjs - regeneratorRuntime 未定义 rete.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60207758/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com