I'm new to Angular 2 CLI. As per tutorial, there is command provided called ng create <project_name>
. My scenario is creating project in existing directory.
It throws error like below:
Directory 'angular-basic' already exists.
I'm new to Angular 2 CLI. As per tutorial, there is command provided called ng create <project_name>
. My scenario is creating project in existing directory.
It throws error like below:
Directory 'angular-basic' already exists.
you can use yarn package manager to resolve the dependencies of the existing project. For more information check this answer.
Since the ng init
command is removed from the CLI commands what you can do is specify the directory. You might have to do some overwrites and modifications by yourself for some of the existing files.
You can pull it off with
ng new [app_name] --directory=directory_path
Example assume that your terminal is opened in angular-basic directory and you have to add the cli to angular-basic project, ng new angular-basic --directory .
would create the workspace in current directory which is angular-basic.
UPDATE:
Reason that it has been removed is because of the message of having two ways to create a project and because people were using it to upgrade (poorly) - From cli team @Brocco's tweet.
This is easy enough.
Run the following command from the existing directory which will serve as your application root.
$ ng new
current-directory
--directory=./
--skip-install
This uses three arguments as:
current-directory whatever your project name will be or current location where terminal is open.
--directory=./ this what does the magic, it instructs angular-cli to use existing folder as project root.
Just in case you see an error like The Schematic workflow failed. See above., clear the contents of your directory, specially README.md
, .gitignore
etc. and let angular-cli create them for you.
Try
ng init
will create project inside your existing directory then dong serve
.Refer: https://cli.angular.io/reference.pdf