Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng <command> --help does not work #16241

Open
KissBalazs opened this issue Nov 20, 2019 · 6 comments
Open

ng <command> --help does not work #16241

KissBalazs opened this issue Nov 20, 2019 · 6 comments

Comments

@KissBalazs
Copy link

@KissBalazs KissBalazs commented Nov 20, 2019

🐞 bug report

Affected Package

The issue is caused by package @angular/cli

Is this a regression?

not sure.

Description

Angular cli commands seems to be working, but the --help flag does not work in them in angular 8. It is suggested in the documentation in multiple places that it should.

🔬 Minimal Reproduction

(npm uninstall -g @angular/cli)
npm install -g @angular/cli@latest
ng generate --help

🔥 Exception or Error

forest@forest:~$ ng generate --help

An unhandled exception occurred: Unable to locate a workspace file for workspace path.
See "/tmp/ng-s4wanw/angular-errors.log" for further details.

forest@forest:~$ cat /tmp/ng-MYDOue/angular-errors.log

[error] Error: Unable to locate a workspace file for workspace path.
    at Object.readWorkspace (/home/forest/.nvm/versions/node/v12.3.1/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/workspace/core.js:74:19)
    at async GenerateCommand._loadWorkspace (/home/forest/.nvm/versions/node/v12.3.1/lib/node_modules/@angular/cli/models/schematic-command.js:442:35)
    at async GenerateCommand.initialize (/home/forest/.nvm/versions/node/v12.3.1/lib/node_modules/@angular/cli/models/schematic-command.js:40:9)
    at async GenerateCommand.initialize (/home/forest/.nvm/versions/node/v12.3.1/lib/node_modules/@angular/cli/commands/generate-impl.js:12:9)
    at async GenerateCommand.validateAndRun (/home/forest/.nvm/versions/node/v12.3.1/lib/node_modules/@angular/cli/models/command.js:124:9)
    at async Object.runCommand (/home/forest/.nvm/versions/node/v12.3.1/lib/node_modules/@angular/cli/models/command-runner.js:186:24)
    at async default_1 (/home/forest/.nvm/versions/node/v12.3.1/lib/node_modules/@angular/cli/lib/cli/index.js:54:31)forest@forest:~$ ^C

🌍 Your Environment

Angular Version:


Angular CLI: 8.3.19
Node: 12.3.1
OS: linux x64
Angular: 
... 

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.803.19
@angular-devkit/core         8.3.19
@angular-devkit/schematics   8.3.19
@schematics/angular          8.3.19
@schematics/update           0.803.19
rxjs                         6.4.0

Anything else relevant?

@santoshyadavdev
Copy link
Contributor

@santoshyadavdev santoshyadavdev commented Nov 20, 2019

Are you trying to run this from inside a Angular project? Or globally , to use ng generate --help you need to be inside an Angular workspace. Let me know if that works, we can update the docs if needed.

@KissBalazs
Copy link
Author

@KissBalazs KissBalazs commented Nov 20, 2019

Yep, that was the problem. Outside of an angular project, ng new --help works, ng generate --help does not. Inside they both works.

Although this might be a source of misunderstanding. Using the --help flag produces a different error than using the command itself:
forest@forest:~/projects$ ng generate
The generate command requires to be run in an Angular project, but a project definition could not be found.
forest@forest:~/projects$ ng generate --help
An unhandled exception occurred: Unable to locate a workspace file for workspace path. See "/tmp/ng-QM4fsM/angular-errors.log" for further details.

Best solution could be updating the error message a bit maybe. Thank you for the help!

@santoshyadavdev
Copy link
Contributor

@santoshyadavdev santoshyadavdev commented Nov 20, 2019

That's a good suggestion @alan-agius4 what's your thought on this?

@alan-agius4 alan-agius4 transferred this issue from angular/angular Nov 20, 2019
@alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented Nov 20, 2019

We should fix this 😊

@ngbot ngbot bot added this to the Backlog milestone Nov 20, 2019
arturovt added a commit to arturovt/angular-cli that referenced this issue Dec 9, 2019
arturovt added a commit to arturovt/angular-cli that referenced this issue Dec 9, 2019
arturovt added a commit to arturovt/angular-cli that referenced this issue Dec 9, 2019
arturovt added a commit to arturovt/angular-cli that referenced this issue Dec 11, 2019
arturovt added a commit to arturovt/angular-cli that referenced this issue Dec 11, 2019
arturovt added a commit to arturovt/angular-cli that referenced this issue Dec 17, 2019
@alan-agius4 alan-agius4 mentioned this issue Jan 10, 2020
1 of 1 task complete
@imrvasishtha
Copy link

@imrvasishtha imrvasishtha commented May 5, 2020

Please try to update the docs also because it can create a problem for person like me who is new in angular. Thanks. cli#basic-workflow

@kuncevic
Copy link
Contributor

@kuncevic kuncevic commented Oct 18, 2020

Oh I believe it is really confused people who just new to angular cli and might be a kinda blocker for some, so this ng command --help should just work

Here is the list of commands that does not work outside the angular project #19057:

ng build --help
ng serve --help
ng test --help
ng e2e --help
ng generate --help
ng add --help
ng lint --help
ng xi18n --help
ng run --help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants
You can’t perform that action at this time.