我有一个项目,我已从 Angular 7.2 升级到 Angular 8,升级后 ng serve 命令无法启动应用程序。ng serve 命令报告它无法找到应用程序。
我阅读了有关 angular 和 angular.json 文件的文档。项目名称没有改变。ng upgrade 命令执行的更新除外。当我检查日志时,它报告该项目不存在。
我已经用给出的 angular.json 文件尝试了“ng serve”和“ng server publicfrontend”。
angular.json 文件
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"publicfrontend": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/favicon",
"src/favicon.ico",
"src/manifest.json"
],
"styles": [
"node_modules/bootstrap/scss/bootstrap.scss",
"node_modules/font-awesome/css/font-awesome.css",
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"serviceWorker": true,
"ngswConfigPath": "src/ngsw-config.json",
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"devserv": {
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "angular:build"
},
"configurations": {
"production": {
"browserTarget": "angular:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [],
"styles": [
"node_modules/font-awesome/css/font-awesome.css",
"node_modules/bootstrap/scss/bootstrap.scss",
"src/styles.css"
],
"assets": ["src/assets", "src/favicon", "src/favicon.ico"]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": ["src/tsconfig.app.json", "src/tsconfig.spec.json"],
"exclude": ["**/node_modules/**"]
}
},
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/publicfrontend-server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json"
},
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"sourceMap": false,
"optimization": {
"scripts": false,
"styles": true
}
}
}
},
"app-shell": {
"builder": "@angular-devkit/build-angular:app-shell",
"options": {
"browserTarget": "publicfrontend:build",
"serverTarget": "publicfrontend:server",
"route": "app-shell=path"
},
"configurations": {
"production": {
"browserTarget": "publicfrontend:build:production",
"serverTarget": "publicfrontend:server:production"
}
}
}
}
}
},
"defaultProject": "publicfrontend",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "css"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}
Erics-MacBook-Pro:PublicFrontend naujocke$ ng serve
An unhandled exception occurred: Project does not exist.
See "/private/var/folders/dh/c9j6szpn72g1l1vfkcfb3kyh0000gp/T/ng-6HErtU/angular-errors.log" for further details.
This is the output of the log file.
[error] Error: Project does not exist.
at WorkspaceNodeModulesArchitectHost.findProjectTarget (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:94:23)
at WorkspaceNodeModulesArchitectHost.getOptionsForTarget (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:66:33)
at core_1.experimental.jobs.createJobHandler.name (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/src/architect.js:171:21)
at Observable._subscribe (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node_modules/@angular-devkit/core/src/experimental/jobs/create-job-handler.js:91:26)
at Observable._trySubscribe (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:44:25)
at Observable.subscribe (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Observable.js:30:22)
at /Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/util/subscribeTo.js:22:31
at Object.subscribeToResult (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/util/subscribeToResult.js:10:45)
at SwitchMapSubscriber._innerSub (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/operators/switchMap.js:65:54)
at SwitchMapSubscriber._next (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/operators/switchMap.js:55:14)
at SwitchMapSubscriber.Subscriber.next (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Subscriber.js:66:18)
at SafeSubscriber.__tryOrUnsub (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular/cli/node_modules/rxjs/internal/Subscriber.js:207:16)
at SafeSubscriber.next (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular/cli/node_modules/rxjs/internal/Subscriber.js:145:22)
at Subscriber._next (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular/cli/node_modules/rxjs/internal/Subscriber.js:89:26)
at Subscriber.next (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular/cli/node_modules/rxjs/internal/Subscriber.js:66:18)
at SafeSubscriber.__tryOrUnsub (/Users/naujocke/Wakanda/solutions/CoronersOffice/PublicFrontend/node_modules/@angular-devkit/architect/node_modules/rxjs/internal/Subscriber.js:207:16