Angular-cli: Update wiki page documentation

Created on 14 May 2018  路  7Comments  路  Source: angular/angular-cli

Versions

Angular CLI: 6.0.1
Node: 8.9.0
OS: darwin x64 (Mac)
Angular: 6.0.1

Repro steps

  1. run ng --help it list the following commands:
  2. add: Add support for a library to your project.
  3. new: Creates a new directory and a new Angular app.
  4. generate: Generates and/or modifies files based on a schematic.
  5. update: Updates your application and its dependencies.
  6. build: Builds your app and places it into the output path (dist/ by default).
  7. serve: Builds and serves your app, rebuilding on file changes.
  8. test: Run unit tests in existing project.
  9. e2e: Run e2e tests in existing project.
  10. lint: Lints code in existing project.
  11. xi18n: Extracts i18n messages from source code.
  12. run: Runs Architect targets.
  13. eject: Temporarily disabled. Ejects your app and output the proper webpack configuration and scripts.
  14. config: Get/set configuration values.
  15. help: Help.
  16. version: Outputs Angular CLI version.
  17. doc: Opens the official Angular API documentation for a given keyword.

Observed behavior

Lack of documentation for the following commands in the wiki page:
1. ng run 
2. ng add
3. ng eject

and 

1. `ng run --help` throws the error 
Cannot determine project or target for Architect command.
Error: Cannot determine project or target for Architect command.

Desired behavior

Please provide appropriate documentation for the listed commands on the wiki page.
and

1. `ng run --help` command should show help manual.

and 

Running test case for the projects inside the workspace should be documented on the wiki
e.g: `ng test my-lib` run test cases for my-lib project



angulacli docs

Most helpful comment

I got a similar error. Executing the command

ng build --target=production --configuration=prod --aot=true --source-map=true

resulted in

Error: Cannot determine project or target for Architect command.

I finally found that I needed to change the command to

ng run my-project:build:prod --target=production --aot=true --source-map=true

The wiki page about ng run is outdated.

All 7 comments

So after checking out the source code, it appears that ng run expects one argument in the form project_name:architect_target. For example, if your angular.json had something like this:

  "projects": {
    "login": {
      "architect": {
        "build": { ... },
        ...
      },
      ...
    },
    ...
  }

You could ng run login:build (which appears to be the same as calling ng build login). I also notice that different architect targets like "serve" contain an "options" object with a "browserTarget" of the same form (i.e. "login:build"). So perhaps ng run is being used behind the scenes when you call other commands (like ng build login). I'm just speculating.

One thing that ng run allows is the ability to execute arbitrary / custom architect targets (i.e. ng run login:custom_target). Something I haven't figured out how to otherwise do. (a side affect of this seems to be that your architect targets can't contain the character :)

I got a similar error. Executing the command

ng build --target=production --configuration=prod --aot=true --source-map=true

resulted in

Error: Cannot determine project or target for Architect command.

I finally found that I needed to change the command to

ng run my-project:build:prod --target=production --aot=true --source-map=true

The wiki page about ng run is outdated.

What's really bugs me is that they have a defaultProject property, ng run et al should use that as the, well, default instead of throwing an error

@eranation that wouldn't be enough to fix this issue. You need to pass a project and architect target to ng run. Put another way, you're not running a project with this command.

ng lint wiki page is missing the --project option available in ng cli 6.x.

Hi all, Documentation for the CLI has been moved to https://angular.io/cli.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings