27
C:\Users\muhiuddin.TOWERTECH\test\testapp>ng build --target=production

or

C:\Users\muhiuddin.TOWERTECH\test\testapp>ng run

When I run a new project or build it give me "Cannot determine project or target for Architect command" error. I am new to Angular. Kindly give me easy solution.

Angular CLI: 6.0.8
Node: 9.3.0
OS: win32 x64
Angular: 6.0.7
>Cannot determine project or target for Architect command.
Error: Cannot determine project or target for Architect command.
    at MergeMapSubscriber._loadWorkspaceAndArchitect.pipe.operators_1.concatMap [as project] (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\@angular\cli\models\architect-command.js:62:27)
    at MergeMapSubscriber._tryNext (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\rxjs\internal\operators\mergeMap.js:65:27)
    at MergeMapSubscriber._next (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\rxjs\internal\operators\mergeMap.js:55:18)
    at MergeMapSubscriber.Subscriber.next (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\rxjs\internal\Subscriber.js:64:18)
    at TapSubscriber._next (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\rxjs\internal\operators\tap.js:62:26)
    at TapSubscriber.Subscriber.next (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\rxjs\internal\Subscriber.js:64:18)
    at MergeMapSubscriber.notifyNext (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\rxjs\internal\operators\mergeMap.js:84:26)
    at InnerSubscriber._next (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\rxjs\internal\InnerSubscriber.js:25:21)
    at InnerSubscriber.Subscriber.next (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\rxjs\internal\Subscriber.js:64:18)
    at MapSubscriber._next (C:\Users\muhiuddin.TOWERTECH\test\testapp\node_modules\rxjs\internal\operators\map.js:52:26)
Amnon
  • 2,212
  • 1
  • 19
  • 35
MUHIUDDIN
  • 323
  • 1
  • 4
  • 10
  • Look at the ng (https://github.com/angular/angular-cli/wiki) CLI Wiki. `ng run` is like _execute_ something, not _run my app_. `ng serve` or `ng run :serve` seems like what you were trying. Some syntax changed a little in 6. – Jason Alexander Aug 21 '18 at 01:46

8 Answers8

32

Use:

ng serve

See angular CLI docs - https://github.com/angular/angular-cli/wiki

Nathan Alard
  • 1,753
  • 17
  • 9
22

Double check command line syntax. This error can show if ng used instead of npm like when using package.json shortcut scripts.

npm run debug   (Good)
ng run debug    (Bad)
SushiGuy
  • 1,573
  • 17
  • 20
7

Check out the cli documentation.

I believe you need to specify your project's name in the build command.

ng build [project]

Also you can do the production build with the following command.

ng build [project] --prod

bodorgergely
  • 558
  • 1
  • 3
  • 12
  • thanks both your example working fine now. But i still get same error on run. eg "ng run [project]" – MUHIUDDIN Jul 09 '18 at 04:58
  • @MUHIUDDIN There is an issue on github in the angular-cli repo about not showing enough information to the user about this very same error message. Check it out: https://github.com/angular/angular-cli/issues/10955 – bodorgergely Jul 09 '18 at 05:49
  • @MUHIUDDIN for the `run` command try this: ng run needs a target in the format of project:target and is erroring out because of that. – bodorgergely Jul 09 '18 at 05:52
7

had this after upgrading to angular 6.

appears like the CLI command has changed to :

ng build --configuration <environment-name>

the migration from 5 to 6 also created a new "angular.json" file which now contains all the different configurations and their names.

Nir
  • 1,225
  • 12
  • 8
1

Update angular.json file. Add defaultProject property (value will be the name of the desired project)

Vivek Kasture
  • 301
  • 1
  • 3
  • 14
0

In Angular version 6, the build command is changed. Changing "build": "ng build --target=production --aot=true" to "build": "ng build --prod --aot" in package.json worked for me.

Nodira
  • 656
  • 1
  • 9
  • 23
0

I had a similar problem after cloning the project from my repository on another machine. I used the commands:

$ npm link

$ ng serve
0

I had a similar problem after update the project from main branch.

I used the command: npm install

If node requires a minimum Node.js version >= v14.15.

sudo npm cache clean -f /
sudo npm install -g n /
sudo n stable /

For changing node versions

nvm install v16.10.         # Install v16.10.
nvm use v16.10.             # Use v16.10.
Ivan Lynch
  • 563
  • 5
  • 23