Converting an existing angular 2 project to use angular CLI

后端 未结 4 1748
萌比男神i
萌比男神i 2021-01-01 10:23

I have a project that was not created using ng new (rather, I followed the quickstart guide). When I run an angular CLI command in that project (such as n

4条回答
  •  猫巷女王i
    2021-01-01 10:53

    You should be able to run ng init and follow the prompts. Have a look at this issue if you need some guidance: https://github.com/angular/angular-cli/issues/755

    Edit (March 13, 2017):

    ng-init was removed from the latest version of the angular cli. https://github.com/angular/angular-cli/pull/4628

    So for now you'll need to resort to mimicking what it tried to accomplish. ie:

    1. Create a new angular project ng new myTemplate

    2. Copy relevant files to your existing project from your new myTemplate project:

      .angular-cli.json package.json tslint.json src/polyfills.ts src/styles.css src/tsconfig.json

    Depending on the state of your existing application you may want to copy over way more or way less. I guess this is why the feature was removed from the CLI. There isn't really any way for it to know exactly what you want it to do.

提交回复
热议问题