Bird
0
0

You ran ng generate component nav-bar but got an error. What is the likely cause?

medium📝 Debug Q14 of 15
Angular - Components
You ran ng generate component nav-bar but got an error. What is the likely cause?
AYou must run the command inside an Angular project folder
BComponent names cannot contain hyphens
CThe CLI command should be <code>ng create component nav-bar</code>
DComponent names must be uppercase
Step-by-Step Solution
Solution:
  1. Step 1: Check the environment for running CLI commands

    Angular CLI commands must be run inside an Angular project folder where configuration files exist.
  2. Step 2: Verify the command syntax and naming rules

    Hyphens are allowed in component names, and the command is ng generate component, not ng create. Component names can be lowercase.
  3. Final Answer:

    You must run the command inside an Angular project folder -> Option A
  4. Quick Check:

    Run CLI commands inside Angular project folder [OK]
Quick Trick: Always run CLI commands inside your Angular project folder [OK]
Common Mistakes:
  • Trying to run commands outside the project folder
  • Using 'ng create' instead of 'ng generate'
  • Thinking hyphens are invalid in names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes