[Angular-CLI-6]Could not determine single project for 'Serve' target
Asked Answered
S

2

13

I have updated my angular-cli with the help of ng update @angular/cli command. After that, I have got an error as Could not determine single project for 'server' target with following error trace.

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

This behaviour is quite confusing me. For more information i am also adding my package.json here.

{
  "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"
  }
}

Here, I am getting why this error is occur. Can anyone help me to resolve it?

Sabrasabre answered 16/7, 2018 at 18:47 Comment(3)
It looks like the update did not complete successfully because your package.json file is still referencing Angular 5 libraries.Manzanilla
@msanford:- an update of angular/core package is required along with cli update. Thank you so much for your help and attention.Sabrasabre
I missed the crucial fact that you were updating to 6. As such my original comment is irrelevant and @DeborahK's answer is obviously the correct one! I've replaced the angular6. tagFilaria
M
13

Did you follow all three steps of the update process?

The update generally follows 3 steps, and will take advantage of the new ng update tool.

1) Update @angular/cli:

npm install -g @angular/cli
npm install @angular/cli
ng update @angular/cli

2) Update your Angular framework packages:

ng update @angular/core

3) Update other dependencies

See toward the bottom of this post for more information: https://blog.angular.io/version-6-of-angular-now-available-cc56b0efa7a4

See also this link for the set of steps: https://update.angular.io/

Manzanilla answered 16/7, 2018 at 19:36 Comment(1)
Hi, Thank you so much for your response. I am successfully able to update angular 6. Mentioned resource worked for me. In addition to that i found there is migrator is also required for converting .angular-cli.json to angular.json.Sabrasabre
N
0

Angular 6 has a feature added known as library. I just upgraded my universal project from angular 4 to 6 which lead to the error above in my case the problem was the script below:

    "build:client-and-server-bundles": "ng build --prod && ng run project-name:server:production",

I fixed it by amending my project name to the script as below:

    "build:client-and-server-bundles": "ng build my-main-project-name --prod && ng run my-main-project-name:server:production",

So the change was with build command so now your ng build --prod command will be changed to ng build --prod my-main-project-name due to library you can have multiple project without letting them interfere with one another. So you'll need to specify the project you want to build.

Nival answered 4/11, 2018 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.