[Angular-CLI-6]无法确定 'Serve' 目标的单个项目
[Angular-CLI-6]Could not determine single project for 'Serve' target
我已经在 ng update @angular/cli
命令的帮助下更新了我的 angular-cli。在那之后,我得到一个错误 Could not determine single project for 'server' target
和以下错误跟踪。
Could not determine a single project for the 'serve' target.
Error: Could not determine a single project for the 'serve' target.
at ServeCommand.getProjectNamesByTarget (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:175:19)
at ServeCommand.<anonymous> (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:128:51)
at Generator.next (<anonymous>)
at E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:7:71
at new Promise (<anonymous>)
at __awaiter (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:3:12)
at ServeCommand.runArchitectTarget (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:121:16)
at ServeCommand.<anonymous> (E:\Angular\Projects\projectName\node_modules\@angular\cli\commands\serve.js:34:25)
at Generator.next (<anonymous>)
at E:\Angular\Projects\projectName\node_modules\@angular\cli\commands\serve.js:7:71
这种行为让我很困惑。
有关更多信息,我还在此处添加我的 package.json
。
{
"name": "ProjectName",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~6.0.8",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3",
"@angular-devkit/build-angular": "~0.6.8"
}
}
在这里,我明白了为什么会出现这个错误。谁能帮我解决一下?
您是否遵循了更新过程的所有三个步骤?
更新一般分为3个步骤,会利用新的ng更新工具。
1) 更新@angular/cli:
npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli
2) 更新您的 Angular 框架包:
ng update @angular/core
3) 更新其他依赖项
有关详细信息,请参阅此 post 的底部:https://blog.angular.io/version-6-of-angular-now-available-cc56b0efa7a4
另请参阅此 link 以了解这组步骤:https://update.angular.io/
Angular 6 添加了一个称为库的功能。我刚刚将我的通用项目从 angular 4 升级到 6,这导致了上面的错误,在我的例子中,问题是下面的脚本:
"build:client-and-server-bundles": "ng build --prod && ng run project-name:server:production",
我通过将我的项目名称修改为脚本来修复它,如下所示:
"build:client-and-server-bundles": "ng build my-main-project-name --prod && ng run my-main-project-name:server:production",
所以更改是通过构建命令进行的,所以现在您的 ng build --prod
命令将更改为 ng build --prod my-main-project-name
由于库,您可以拥有多个项目而不会让它们相互干扰。因此,您需要指定要构建的项目。
我已经在 ng update @angular/cli
命令的帮助下更新了我的 angular-cli。在那之后,我得到一个错误 Could not determine single project for 'server' target
和以下错误跟踪。
Could not determine a single project for the 'serve' target.
Error: Could not determine a single project for the 'serve' target.
at ServeCommand.getProjectNamesByTarget (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:175:19)
at ServeCommand.<anonymous> (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:128:51)
at Generator.next (<anonymous>)
at E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:7:71
at new Promise (<anonymous>)
at __awaiter (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:3:12)
at ServeCommand.runArchitectTarget (E:\Angular\Projects\projectName\node_modules\@angular\cli\models\architect-command.js:121:16)
at ServeCommand.<anonymous> (E:\Angular\Projects\projectName\node_modules\@angular\cli\commands\serve.js:34:25)
at Generator.next (<anonymous>)
at E:\Angular\Projects\projectName\node_modules\@angular\cli\commands\serve.js:7:71
这种行为让我很困惑。
有关更多信息,我还在此处添加我的 package.json
。
{
"name": "ProjectName",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.2.0",
"@angular/common": "^5.2.0",
"@angular/compiler": "^5.2.0",
"@angular/core": "^5.2.0",
"@angular/forms": "^5.2.0",
"@angular/http": "^5.2.0",
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"core-js": "^2.4.1",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
"devDependencies": {
"@angular/cli": "~6.0.8",
"@angular/compiler-cli": "^5.2.0",
"@angular/language-service": "^5.2.0",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.8.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~2.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~4.1.0",
"tslint": "~5.9.1",
"typescript": "~2.5.3",
"@angular-devkit/build-angular": "~0.6.8"
}
}
在这里,我明白了为什么会出现这个错误。谁能帮我解决一下?
您是否遵循了更新过程的所有三个步骤?
更新一般分为3个步骤,会利用新的ng更新工具。
1) 更新@angular/cli:
npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli
2) 更新您的 Angular 框架包:
ng update @angular/core
3) 更新其他依赖项
有关详细信息,请参阅此 post 的底部:https://blog.angular.io/version-6-of-angular-now-available-cc56b0efa7a4
另请参阅此 link 以了解这组步骤:https://update.angular.io/
Angular 6 添加了一个称为库的功能。我刚刚将我的通用项目从 angular 4 升级到 6,这导致了上面的错误,在我的例子中,问题是下面的脚本:
"build:client-and-server-bundles": "ng build --prod && ng run project-name:server:production",
我通过将我的项目名称修改为脚本来修复它,如下所示:
"build:client-and-server-bundles": "ng build my-main-project-name --prod && ng run my-main-project-name:server:production",
所以更改是通过构建命令进行的,所以现在您的 ng build --prod
命令将更改为 ng build --prod my-main-project-name
由于库,您可以拥有多个项目而不会让它们相互干扰。因此,您需要指定要构建的项目。