现有github项目的Angular cli

Sac*_*hin 8 angular-cli

我是Angular 2 CLI的新手.根据教程,提供了一个名为的命令."创造".我的方案是在现有目录中创建项目.

它会抛出错误,如下面的目录'angular-basic'已经存在.

Sai*_*ouk 12

由于ng init命令已从CLI命令中删除,因此您可以指定目录.对于某些现有文件,您可能需要自己进行一些覆盖和修改.

你可以把它拉下来

ng new [app_name] --directory=directory_path

示例假设您的终端在angular-basic目录中打开,并且您必须将cli添加到angular-basic项目,ng new angular-basic --directory .会做得更好.

更新:

它被删除的原因是因为有两种方法来创建一个项目,而且因为人们使用它来升级(很差) - 来自cli团队@Brocco的推文.

  • 实际上你可以更容易地做到这一点`ng new [app_name] --directory .` (8认同)

rac*_*arg 8

这很容易。

从现有目录运行以下命令,该目录将用作您的应用程序根目录。

$ ng new current-directory--directory=./ --skip-install

这使用三个参数:

  1. current-directory无论您的项目名称是什么或终端打开的当前位置。

  2. --directory=./这有什么神奇之处,它指示 angular-cli 使用现有文件夹作为项目根目录。

  3. --skip-install这个是完全可选的,只会阻止预先安装所有 npm 依赖项。

以防万一您看到“原理图工作流失败”等错误看上面。, 清除目录中的内容,特别README.md.gitignore等,并让 angular-cli 为您创建它们。


Tem*_*dze 8

尝试这个命令:

ng new appName --directory ./
Run Code Online (Sandbox Code Playgroud)


Ven*_*t.R 4

尝试ng init在现有目录中创建项目,然后执行ng serve.

ng init <project-name> [options]
Creates a new Angular project in the current folder.

Options:
 --dry-run only output the files created and operations performed, do
 not actually create the project.

 Alias: 'd'.
 --verbose output more information.

 Alias: 'v'.
 --skip-npm do not run any npm command once the project is created.
 --name The name of the project to create.
Run Code Online (Sandbox Code Playgroud)

对于新的 Angular 2.x 项目

ng new foo
cd foo
npm link angular-cli
ng serve
Run Code Online (Sandbox Code Playgroud)

参考: https: //cli.angular.io/reference.pdf