首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >regeneratorRuntime未定义为rete.js

regeneratorRuntime未定义为rete.js
EN

Stack Overflow用户
提问于 2020-02-13 12:21:57
回答 1查看 1.1K关注 0票数 3

我能为我的问题找到解决办法。我正在尝试在Rete.js中使用Next.js中的打字本。我看到以下错误:

未定义

regeneratorRuntime

这是我的配置

package.json

代码语言:javascript
复制
"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

代码语言:javascript
复制
{
  "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

代码语言:javascript
复制
{
    "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,并尝试如下:

代码语言:javascript
复制
import "core-js/stable";
import "regenerator-runtime/runtime";

但对我没什么用。你能提出一些能解决我问题的建议吗。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-18 06:47:24

不需要安装core-jsregenerator-runtime@babel/plugin-transform-runtime提供了所需的运行时。我只是错过了一个基本的东西,没有添加@babel/preset-env。我假设next/babel包含了.babelrc文件所需的所有内容,但事实并非如此。下面是对我有用的最后一个.babelrc文件。

代码语言:javascript
复制
{
    "presets": [
        "@babel/preset-env",
        "next/babel"
      ],
      "plugins": [
        ["@babel/plugin-transform-runtime"]
      ]     
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60207758

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档