angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Can we use angular-cli after a project has been already been created by using git clone of Angular Quickstart

Open brookhutchinson opened this issue 9 years ago • 5 comments

Please provide us with the following information:

OS?

Windows 10

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:1.0.0-beta.24

Repro steps.

Was this an app that wasn't created using the CLI? Yes. What change did you do on your code? I am wondering if I can introduce angular-cli to an already created project

The log given by the failure.

Normally this include a stack trace and some more information.

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

brookhutchinson avatar Jan 16 '17 01:01 brookhutchinson

@brookhutchinson the easiest way to do this is to create a new app with angular-cli and move to modules/components/services and other parts from the old app into the new one.

beeman avatar Jan 16 '17 01:01 beeman

I prefer to create new projects using angular-cli. @beeman I understand what you are saying.

The intention of my question was to have one and only one Angular Project (instead of having to create a second project using the angular-cli). Is it possible to install and use the angular-cli inside a project that was not originally created with the angular-cli?

brookhutchinson avatar Jan 16 '17 02:01 brookhutchinson

Angular CLI makes certain assumptions about the directory structure, naming of files and the existence and versions of its dependencies.

While it is possible to re-create this structure manually, you will probably end up creating a new project with the cli as a reference and rework/copy the structure into your existing app. You will end up with basically the same result, but with a lot more work.

So yeah, it is possible to do so. I have added angular-cli and it's dependencies and structure to about 6 Angular 1 projects at work, mainly to use its webpack infrastructure and to add NG2+ support to my current NG1 projects, but I would not recommend doing so if there's an alternative.

Starting with a fresh app and copying your existing code in there will most likely be quicker and less buggy.

beeman avatar Jan 16 '17 03:01 beeman

Assuming https://github.com/angular/quickstart, these are the steps needed to use the ng serve on it:

  • npm install angular-cli@latest --save-dev
  • add ./angular-cli.json:
{
  "apps": [
    {
      "root": ".",
      "main": "app/main.ts",
      "styles": [
        "styles.css"
      ],
      "scripts": [
        "./node_modules/core-js/client/shim.min.js",
        "./node_modules/zone.js/dist/zone.js"
      ]
    }
  ]
}
  • remove all link/script tags from ./index.html:
<!DOCTYPE html>
<html>
  <head>
    <title>Angular QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  </head>

  <body>
    <my-app>Loading AppComponent content here ...</my-app>
  </body>
</html>
  • ng serve

That's it!

If you want e2e and unit tests to work, it's better to just copy quickstart's app/ dir onto a CLI project instead.

filipesilva avatar Jan 16 '17 11:01 filipesilva

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.