简体   繁体   English

发生未处理的异常:项目“app”不存在。 离子服务后收到此错误

[英]An unhandled exception occurred: Project "app" does not exist. getting this error after ionic serve

At first I used command:起初我使用命令:

ng add @ionic/angular

To add ionic to my Angular 7 project.将离子添加到我的 Angular 7 项目中。

As title says I am getting this error: An unhandled exception occurred: Project "app" does not exist when I am trying to serve my Angular7/Ionic 4 project by command:正如标题所说,我收到此错误:发生未处理的异常:当我尝试通过命令为我的 Angular7/Ionic 4 项目提供服务时,项目“应用程序”不存在:

ionic serve

I read about inconsistent project names causing this problem but they seem fine to me.我读到了导致此问题的不一致的项目名称,但对我来说它们似乎很好。 Here are my related files:这是我的相关文件:

angular.json angular.json

    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "Angular7": {
      "projectType": "application",
      "schematics": {},
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/Angular7",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/favicon.ico",
              "src/assets",
              {
                "glob": "**/*.svg",
                "input": "node_modules/ionicons/dist/ionicons/svg",
                "output": "./svg"
              }
            ],
            "styles": [
              "src/styles.css",
              {
                "input": "node_modules/@ionic/angular/css/normalize.css"
              },
              {
                "input": "node_modules/@ionic/angular/css/structure.css"
              },
              {
                "input": "node_modules/@ionic/angular/css/typography.css"
              },
              {
                "input": "node_modules/@ionic/angular/css/core.css"
              },
              {
                "input": "node_modules/@ionic/angular/css/padding.css"
              },
              {
                "input": "node_modules/@ionic/angular/css/float-elements.css"
              },
              {
                "input": "node_modules/@ionic/angular/css/text-alignment.css"
              },
              {
                "input": "node_modules/@ionic/angular/css/text-transformation.css"
              },
              {
                "input": "node_modules/@ionic/angular/css/flex-utils.css"
              },
              {
                "input": "src/theme/variables.css"
              }
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "Angular7:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "Angular7:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "Angular7:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "Angular7:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "Angular7:serve:production"
            }
          }
        },
        "ionic-cordova-serve": {
          "builder": "@ionic/angular-toolkit:cordova-serve",
          "options": {
            "cordovaBuildTarget": "Angular7:ionic-cordova-build",
            "devServerTarget": "Angular7:serve"
          },
          "configurations": {
            "production": {
              "cordovaBuildTarget": "Angular7:ionic-cordova-build:production",
              "devServerTarget": "Angular7:serve:production"
            }
          }
        },
        "ionic-cordova-build": {
          "builder": "@ionic/angular-toolkit:cordova-build",
          "options": {
            "browserTarget": "Angular7:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "Angular7:build:production"
            }
          }
        }
      }
    }
  },
  "defaultProject": "Angular7"
}

package.json:包.json:

{
  "name": "angular7",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~10.1.2",
    "@angular/common": "~10.1.2",
    "@angular/compiler": "~10.1.2",
    "@angular/core": "~10.1.2",
    "@angular/forms": "~10.1.2",
    "@angular/platform-browser": "~10.1.2",
    "@angular/platform-browser-dynamic": "~10.1.2",
    "@angular/router": "~10.1.2",
    "@ionic/angular": "^5.3.4",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1001.2",
    "@angular/cli": "~10.1.2",
    "@angular/compiler-cli": "~10.1.2",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "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",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2",
    "@ionic/angular-toolkit": "latest"
  }
}

ionic.config.json ionic.config.json

{
  "name": "Angular7",
  "integrations": {},
  "type": "angular"
}

I couldn't figure out what to do我不知道该怎么做

The cause of the problem is the name of your default project and its builds.问题的原因是您的默认项目及其构建的名称。 For some reason, Ionic has a problem in resolving it.出于某种原因,Ionic 在解决它时遇到了问题。 I didn't find a direct answer in the docs , but using multi-project configuration seems to work.我没有在docs 中找到直接答案,但使用多项目配置似乎有效。 If you change your ionic.config.json to look like:如果您将ionic.config.json更改为如下所示:

{
  "defaultProject": "Angular7",
  "projects": {
    "Angular7": {
      "name": "Angular7",
      "integrations": {},
      "type": "angular"
    }
  }
}

then it should work with your changed name.那么它应该与您更改的名称一起使用。

Jakubs answer above solved my problem completely.上面的 Jakubs 回答完全解决了我的问题。 I was wracking my brain for 3 days before coming across this page.在看到这个页面之前,我绞尽脑汁 3 天。 Now im wondering why Ionic requires a nested name tag in it config file?现在我想知道为什么 Ionic 需要在它的配置文件中嵌套名称标签?

{ "defaultProject": "Angular7", "projects": { "Angular7": { "name": "Angular7", "integrations": {}, "type": "angular" } } } { "defaultProject": "Angular7", "projects": { "Angular7": { "name": "Angular7", "integrations": {}, "type": "angular" } } }

暂无
暂无

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

相关问题 构建 Ionic v6 cordova android angular13 应用程序返回错误“发生未处理的异常:项目目标不存在。” - Building Ionic v6 cordova android angular13 app returns ERROR "An unhandled exception occurred: Project target does not exist." 发生未处理的异常:项目不存在。 Angular SSR - An unhandled exception occurred: Project does not exist. Angular SSR angular ng serve 命令抛出错误:发生未处理的异常:项目不存在 - angular ng serve command throws error: An unhandled exception occurred: Project does not exist 发生未处理的异常:项目“ngx-mat-miyagi-dolab”不存在。:无法在 Angular 中重新发布 NPM 包 - An unhandled exception occurred: Project 'ngx-mat-miyagi-dolab' does not exist.: cannot republish NPM package in Angular Ng 使用 Angular 10 项目时的构建问题 - [发生未处理的异常:作业名称“..getProjectMetadata”不存在。] - Ng Build issues when using Angular 10 project - [An unhandled exception occurred: Job name “..getProjectMetadata” does not exist.] 发生未处理的异常:作业名称“..getProjectMetadata”不存在 - An unhandled exception occurred: Job name "..getProjectMetadata" does not exist 运行 ng serve 发生未处理的异常 - Unhandled exception occurred running ng serve 使用 ng serve 在 angular 中发生未处理的异常 - An unhandled exception occurred in angular using ng serve 错误离子服务确实弹出未处理的例外:NGCC 失败 - ERROR Ionic serve does eject unhandled exeption: NGCC failed 当我执行ng serve -o时,发生未处理的异常:ts.createNodeArray不是函数 - When I am doing ng serve -o then getting an unhandled exception occurred: ts.createNodeArray is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM