我能为我的问题找到解决办法。我正在尝试在Rete.js中使用Next.js中的打字本。我看到以下错误:
未定义
regeneratorRuntime
这是我的配置
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-js和regenerator-runtime,并尝试如下:
import "core-js/stable";
import "regenerator-runtime/runtime";但对我没什么用。你能提出一些能解决我问题的建议吗。
发布于 2020-02-18 06:47:24
不需要安装core-js和regenerator-runtime。@babel/plugin-transform-runtime提供了所需的运行时。我只是错过了一个基本的东西,没有添加@babel/preset-env。我假设next/babel包含了.babelrc文件所需的所有内容,但事实并非如此。下面是对我有用的最后一个.babelrc文件。
{
"presets": [
"@babel/preset-env",
"next/babel"
],
"plugins": [
["@babel/plugin-transform-runtime"]
]
}https://stackoverflow.com/questions/60207758
复制相似问题