1
  1. First installed angular CLI globally:

    npm install @angular/cli@latest -g
    
  2. Then I create an angular project outside using by CLI:

    ng new hello-world
    
  3. Copy .angular-cli.json file into the root my project:

  4. Modify .angular-cli.json file: "root" : "src" change to "root" : "ClientApp"

  5. I Installed angularCli dev in my root project: cd MyProject

  6. Then

    npm install @angular/cli@latest --save-dev
    
  7. I Went to that directory :

    cd ClientApp/app/components
    
  8. Then I wrote: ng g c MyComponentName

It has shown me this screen:

enter image description here

jps
  • 20,041
  • 15
  • 75
  • 79
  • the message say you that you have two or more module.ts in your directory. ng g c MyComponent, furthermore to create the module.ts, module.css, etc, add in the closer module.ts the import and declare – Eliseo Feb 08 '18 at 16:35
  • yes but how can solved that issue? – James Absalem Lintu Feb 08 '18 at 16:37
  • 1
    https://stackoverflow.com/questions/46268181/i-cant-add-new-component-with-angular-cli-in-asp-net-core-spas/46269000#46269000 – R. Richards Feb 08 '18 at 17:00

1 Answers1

0

You need to rename the file app.module.shared.ts To app.module.ts under ClientApp/app and correct the file paths in app.module.browser.ts and app.module.server.ts accordingly.

Tested under:
Environment : Development
Target Framework : netcoreapp2.0
SPA template : angular

jps
  • 20,041
  • 15
  • 75
  • 79
Kifayat Ullah
  • 579
  • 1
  • 5
  • 14