起初我使用了命令:
ng add @ionic/angular
如标题所述,我想将Ionic添加到我的Angular 7项目中。
当我尝试通过命令启动我的Angular 7 / Ionic 4项目时,出现以下错误:An unhandled exception occurred: Project "app" does not exist。
ionic serve
我读到了关于不一致的项目名称导致这个问题的文章,但是它们对我来说看起来很好。
以下是我的相关文件:
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:
{
"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
{
"name": "Angular7",
"integrations": {},
"type": "angular"
}
我不知道该怎么做。
angular.json
中的项目名称匹配,位于projects:
下方。"projects": { "Angular7": { "projectType": "application", "schematics": { "@schematics/angular:component": { "style": "scss" }, "@schematics/angular:application": { "strict": true } } } }
- Lorraine R.