1

I have installed a clean vuejs project and configured it. Everything was okay, until created code using await features. Then after compilation (yarn run serve) I get this message:

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

I've read every similar thread and unfortunately none of these solutions work for me (I mean manual installation of babel plugins, installing regenerator, adding plugins section into babel.config.js file - like here).

My config files:

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"
    ]
}
Hektor
  • 1,845
  • 15
  • 19
  • Did you actually run the command suggested by the error message (swap yarn for npm)? Since Babel is transpiling your async generators it is inserting imports to that package – Aluan Haddad Dec 24 '21 at 00:13
  • @AluanHaddad, yes - of course, with lots of variant (as I said): `$ yarn add regenerator-runtime/runtime.js Internal Error: Invalid descriptor (regenerator-runtime/runtime.js)` – TheJacol2016 Dec 24 '21 at 07:29
  • and even if I perform a (probably) correct version: `yarn add -D regenerator-runtime`, nothing changes - the same error as in original post. – TheJacol2016 Dec 24 '21 at 07:54
  • When I removed `babel.config.js` file, the error disappeared. But... there is problem: `You may need an additional loader to handle the result of these loaders. | import { Prop } from 'vue-property-decorator';`. Was removing babel.config.js really help with anything or just changed appearance priority? – TheJacol2016 Dec 24 '21 at 13:33
  • Firstly, adding `regenerator-runtime` as a development dependency is wrong because it's a normal dependency. Secondly, removing `babel.config.js` is going to break your build process. – Aluan Haddad Dec 24 '21 at 22:57
  • So I was partially right... so are there some problems with babel loading, right? I found tips like [this one](https://stackoverflow.com/a/70095630/5157229) - but it didn't help – TheJacol2016 Dec 25 '21 at 11:50

1 Answers1

0

Try this:

  1. Run: npm i regenerator-runtime
  2. Optional: import regenerator-runtime/runtime into the file where you have the async/await.
  3. Delete node_modules and install again.
Lakshya Raj
  • 1,669
  • 3
  • 10
  • 34