繁体   English   中英

VueJS - 使用异步导致再生器运行时问题

[英]VueJS - using Async causes regenerator-runtime problem

我已经安装了一个干净的 vuejs 项目并进行了配置。 一切都很好,直到使用await功能创建代码。 然后在编译后( yarn run serve )我得到这个消息:

This dependency was not found:

* regenerator-runtime/runtime.js in ./src/repositories/auth-repository.ts, ./src/store/modules/auth.ts and 2 others

To install it, you can run: npm install --save regenerator-runtime/runtime.js

我已经阅读了所有类似的帖子,不幸的是这些解决方案都不适合我(我的意思是手动安装 babel 插件,安装 regenerator,将plugins部分添加到 babel.config.js 文件中 -就像这里一样)。

我的配置文件:

babel.config.js

module.exports = {
    presets: [
        '@vue/cli-plugin-babel/preset'
    ]
}

package.json

{
  "name": "my-project",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:unit": "vue-cli-service test:unit",
    "test:e2e": "vue-cli-service test:e2e",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@sentry/tracing": "^6.13.3",
    "@sentry/vue": "^6.13.3",
    "core-js": "^3.18.2",
    "vue": "^2.6.14",
    "vue-class-component": "^7.2.6",
    "vue-i18n": "^8.26.7",
    "vue-property-decorator": "^9.1.2",
    "vue-router": "^3.5.3",
    "vuetify": "^2.6.1",
    "vuex": "^3.6.2"
  },
  "devDependencies": {
    "@sentry/webpack-plugin": "^1.18.3",
    "@types/jest": "^24.9.1",
    "@types/node": "^17.0.4",
    "@typescript-eslint/eslint-plugin": "^4.33.0",
    "@typescript-eslint/parser": "^4.33.0",
    "@vue/cli-plugin-babel": "4.5.15",
    "@vue/cli-plugin-e2e-cypress": "~4.5.13",
    "@vue/cli-plugin-eslint": "~4.5.13",
    "@vue/cli-plugin-router": "~4.5.13",
    "@vue/cli-plugin-typescript": "~4.5.13",
    "@vue/cli-plugin-unit-jest": "~4.5.13",
    "@vue/cli-plugin-vuex": "~4.5.13",
    "@vue/cli-service": "~4.5.13",
    "@vue/eslint-config-standard": "^5.1.2",
    "@vue/eslint-config-typescript": "^7.0.0",
    "@vue/test-utils": "^1.2.2",
    "eslint": "^6.8.0",
    "eslint-plugin-import": "^2.24.2",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^7.19.1",
    "sass": "~1.32.6",
    "sass-loader": "^10.0.0",
    "tslib": "latest",
    "typescript": "^4.4.3",
    "vue-cli-plugin-vuetify": "~2.4.3",
    "vue-template-compiler": "^2.6.14",
    "vuetify-loader": "^1.7.0",
    "vuex-module-decorators": "^1.0.1"
  },
  "packageManager": "yarn@3.1.1"
}

vue.config.js

module.exports = {
    transpileDependencies: [
        'vuetify'
    ]
}

tsconfig.json

{
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "baseUrl": ".",
        "esModuleInterop": true,
        "experimentalDecorators": true,
        "importHelpers": true,
        "jsx": "preserve",
        "lib": [
            "esnext",
            "dom",
            "dom.iterable",
            "scripthost"
        ],
        "module": "esnext",
        "moduleResolution": "node",
        "noImplicitAny": true,
        "noFallthroughCasesInSwitch": true,
        "noImplicitReturns": true,
        "noImplicitThis": true,
        "paths": {
            "#/*": [ "./*" ],
            "@/*": [ "src/*" ]
        },
        "skipLibCheck": true,
        "sourceMap": true,
        "strict": true,
        "target": "esnext",
        "types": [
            "webpack-env",
            "jest",
            "node"
        ]
    },
    "include": [
        "src/**/*.ts",
        "src/**/*.tsx",
        "src/**/*.vue",
        "tests/**/*.ts",
        "tests/**/*.tsx"
    ],
    "exclude": [
        "node_modules"
    ]
}

尝试这个:

  1. 运行: npm i regenerator-runtime
  2. 可选:将regenerator-runtime/runtime导入到您拥有 async/await 的文件中。
  3. 删除node_modules并重新安装。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM