4. You see this error when running an Angular app: ERROR in src/app/app.module.ts: Unexpected token What is the most likely cause in the app.module.ts file?
medium
A. Missing @NgModule decorator
B. Empty app.component.ts file
C. Syntax error like missing comma or bracket
D. Wrong file extension instead of .ts
Solution
Step 1: Analyze error message
An "Unexpected token" error usually means a syntax mistake like a missing comma or bracket.
Step 2: Check common syntax issues in app.module.ts
Look for missing commas, brackets, or typos in imports or declarations.
Final Answer:
Syntax error like missing comma or bracket -> Option C
Quick Check:
Unexpected token = syntax error [OK]
Hint: Unexpected token means syntax mistake [OK]
Common Mistakes:
Assuming missing decorator causes token error
Blaming wrong file extension without checking syntax
Thinking empty component file causes this error
5. You want to add a new feature module to your Angular app. Where should you place the new module file and what must you do to use it in your app?
hard
A. Place it inside src/app/ and import it in app.module.ts
B. Place it in src/assets/ and reference it in index.html
C. Place it in src/ root and add it to main.ts
D. Place it in src/styles/ and import in styles.css
Solution
Step 1: Locate new module in project structure
Feature modules go inside src/app/ to keep app code organized.
Step 2: Import new module in app.module.ts
To use the new module, import it in app.module.ts so Angular knows about it.
Final Answer:
Place it inside src/app/ and import it in app.module.ts -> Option A
Quick Check:
Feature module location and import = Place it inside src/app/ and import it in app.module.ts [OK]
Hint: Modules live in src/app and must be imported [OK]
Common Mistakes:
Putting modules in assets or styles folders
Forgetting to import the module in app.module.ts
Adding modules to main.ts or index.html incorrectly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.