找不到模块:错误:node_modules/@angular-devkit/build-angular/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js'

sin*_*nan 13 angular

我将我的项目 Angular 版本 14.0.0 降级到 13.0.0 以修复此错误Mat 对话框关闭按钮在 IOS 设备上不起作用

按照 如何降级角度版本?的答案

但降级后,当我尝试通过 ng 服务运行时,我收到此错误

我检查了指定的文件夹,其中存在文件 asyncToGenerator.js

./node_modules/idb/build/index.js:1:0-211 - Error: Module not found: Error: Can't resolve '/Volumes/Macintosh HD/Users/ravi/Public/new_mob/node_modules/@angular-devkit/build-angular/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js' in '/Volumes/Macintosh HD/Users/ravi/Public/new_mob/node_modules/idb/build'
Run Code Online (Sandbox Code Playgroud)

我试过

npm install --save-dev @angular-devkit/build-angular
Run Code Online (Sandbox Code Playgroud)

仍然遇到同样的错误

我的 package.json 文件是

{
  "name": "new-design",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --poll=2000",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-slider/ngx-slider": "^2.0.4",
    "@angular/animations": "^13.0.0",
    "@angular/cdk": "^13.0.0",
    "@angular/common": "^13.0.0",
    "@angular/core": "^13.0.0",
    "@angular/forms": "^13.0.0",
    "@angular/material": "^13.0.0",
    "@angular/platform-browser": "^13.0.0",
    "@angular/platform-browser-dynamic": "^13.0.0",
    "@angular/router": "^13.0.0",
    "@capacitor/app": "1.1.1",
    "@capacitor/browser": "^4.0.1",
    "@capacitor/camera": "^4.0.1",
    "@capacitor/core": "3.6.0",
    "@capacitor/filesystem": "^4.0.1",
    "@capacitor/geolocation": "^4.0.1",
    "@capacitor/haptics": "1.1.4",
    "@capacitor/status-bar": "1.0.8",
    "@ionic/angular": "^6.1.9",
    "@ionic/pwa-elements": "^3.1.1",
    "@teamhive/lottie-player": "^1.0.0",
    "add": "^2.0.6",
    "angularx-social-login": "^4.1.0",
    "card-validator": "^8.1.1",
    "compressorjs": "^1.1.1",
    "crypto-js": "^4.1.1",
    "firebase": "^9.15.0",
    "html-entities": "^2.3.3",
    "libphonenumber-js": "^1.10.12",
    "ng": "^0.0.0",
    "ngx-cookie-service": "^14.0.1",
    "ngx-device-detector": "^4.0.1",
    "ngx-infinite-scroll": "^10.0.1",
    "ngx-webcam": "^0.4.1",
    "rxjs": "~6.6.0",
    "socket.io-client": "^2.5.0",
    "swiper": "^8.4.2",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^13.3.10",
    "@angular-eslint/builder": "~13.0.1",
    "@angular-eslint/eslint-plugin": "~13.0.1",
    "@angular-eslint/eslint-plugin-template": "~13.0.1",
    "@angular-eslint/template-parser": "~13.0.1",
    "@angular/cli": "13.0",
    "@angular/compiler": "^13.0.0",
    "@angular/compiler-cli": "^13.0.0",
    "@angular/language-service": "^13.0.0",
    "@capacitor/cli": "3.6.0",
    "@ionic/angular-toolkit": "^6.0.0",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@types/socket.io-client": "^3.0.0",
    "@typescript-eslint/eslint-plugin": "5.3.0",
    "@typescript-eslint/parser": "5.3.0",
    "eslint": "^7.6.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "30.7.6",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "typescript": "~4.6.4"
  },
  "description": "An Ionic project"
}


Run Code Online (Sandbox Code Playgroud)

降级前我的 package.json 文件是

  "name": "new-design",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve --port 4200 --poll=2000",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular-slider/ngx-slider": "^2.0.4",
    "@angular/animations": "^14.2.7",
    "@angular/cdk": "^14.2.7",
    "@angular/common": "^14.0.0",
    "@angular/core": "^14.0.0",
    "@angular/forms": "^14.0.0",
    "@angular/material": "^14.2.7",
    "@angular/platform-browser": "^14.0.0",
    "@angular/platform-browser-dynamic": "^14.0.0",
    "@angular/router": "^14.0.0",
    "@capacitor/app": "1.1.1",
    "@capacitor/browser": "^4.0.1",
    "@capacitor/camera": "^4.0.1",
    "@capacitor/core": "3.6.0",
    "@capacitor/filesystem": "^4.0.1",
    "@capacitor/geolocation": "^4.0.1",
    "@capacitor/haptics": "1.1.4",
    "@capacitor/status-bar": "1.0.8",
    "@ionic/angular": "^6.1.9",
    "@ionic/pwa-elements": "^3.1.1",
    "@teamhive/lottie-player": "^1.0.0",
    "add": "^2.0.6",
    "angularx-social-login": "^4.1.0",
    "apple-signin-auth": "^1.7.5",
    "card-validator": "^8.1.1",
    "compressorjs": "^1.1.1",
    "crypto-js": "^4.1.1",
    "firebase": "^9.15.0",
    "html-entities": "^2.3.3",
    "libphonenumber-js": "^1.10.12",
    "ng": "^0.0.0",
    "ngx-cookie-service": "^14.0.1",
    "ngx-device-detector": "^4.0.1",
    "ngx-infinite-scroll": "^10.0.1",
    "ngx-toggle-switch": "^2.0.5",
    "ngx-ui-switch": "^1.6.0",
    "ngx-webcam": "^0.4.1",
    "rxjs": "~6.6.0",
    "scriptjs": "^2.5.9",
    "socket.io-client": "^2.5.0",
    "swiper": "^8.4.2",
    "tslib": "^2.2.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.2.6",
    "@angular-eslint/builder": "~13.0.1",
    "@angular-eslint/eslint-plugin": "~13.0.1",
    "@angular-eslint/eslint-plugin-template": "~13.0.1",
    "@angular-eslint/template-parser": "~13.0.1",
    "@angular/cli": "^14.2.6",
    "@angular/compiler": "^14.0.0",
    "@angular/compiler-cli": "^14.0.0",
    "@angular/language-service": "^14.0.0",
    "@capacitor/cli": "3.6.0",
    "@ionic/angular-toolkit": "^6.0.0",
    "@types/jasmine": "~3.6.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "@types/socket.io-client": "^3.0.0",
    "@typescript-eslint/eslint-plugin": "5.3.0",
    "@typescript-eslint/parser": "5.3.0",
    "eslint": "^7.6.0",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-jsdoc": "30.7.6",
    "eslint-plugin-prefer-arrow": "1.2.2",
    "jasmine-core": "~3.8.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~6.3.2",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "~3.0.2",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "typescript": "~4.7.3"
  },
  "description": "An Ionic project"
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我弄这个吗?

小智 56

虽然问题是不久前提出的,但我最近遇到了同样的问题,无法找到@babel/runtime/helpers/esm/asyncToGenerator.js

我采取了两个步骤来解决它。首先,我更新了 NodeJs,其次,我删除了项目目录中的.angular文件夹。

我怀疑删除项目目录中的.angular文件夹可以解决问题。

  • 当然,清除随机的、非版本控制的缓存文件夹再次解决了问题...... (5认同)