0

I am trying to create an angular component in visual studio code. By default, my angular components are in ClientApp. I have some default components in ClientApp. When I tried to add a new angular component in the components folder in ClientApp I get an error.

When I enter "ng g component vehicle-form" I have an error. It says " Invalid path: "vehicle-form" cannot be above the "ClientApp\app" directory." However, my angular components are in the app folder located within the app folder of Client App.

PS C:\Users\Sushi\vega> cd ClientApp
PS C:\Users\Sushi\vega\ClientApp> cd app
PS C:\Users\Sushi\vega\ClientApp\app> cd components
PS C:\Users\Sushi\vega\ClientApp\app\components> ng g component vehicle-form
Invalid path: "vehicle-form" cannot be above the "ClientApp\app" directory

My .angular-cli.json configuration is as listed below.

"apps": [
        {
          "root": "ClientApp",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico"

2 Answers 2

1

If you want to create a component from angular cli then just run the command

  ng g component vehicle-form

From your root directory i.e

 PS C:\Users\Sushi\vega\ClientApp> ng g component vehicle-form
Sign up to request clarification or add additional context in comments.

8 Comments

Tried it. still getting the same error. PS C:\Users\Sushi\vega\ClientApp> ng g component vehicle-form Invalid path: "vehicle-form" cannot be above the "ClientApp\app" directory
Invalid path: "app/vehicle-form" cannot be above the "ClientApp\app" directory. How is it above the "ClientApp\app" directory when I creating from within the ClientApp folder.
Whats your root directory ClientApp or vega, I recently taken a closer look and I think your root directory is vega then you must run angular commands from vega
When I try to create a module from Vega, this is the error that is shown. Error: Could not find an NgModule for the new component. Use the skip-import option to skip importing components in NgModule.
Name of the project is Vega and the root of my angular component is ClientApp, there is where all the other angular components are located.
|
0

try to change

 "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico"

then ng g c vehicle-form

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.