ng new
Creates a new workspace and an initial Angular app.
ng new <name> [options]
ng n <name> [options]
说明
Creates and initializes a new Angular app that is the default project for a new workspace.
Provides interactive prompts for optional configuration, such as adding routing support. All prompts can safely be allowed to default.
The new workspace folder is given the specified project name, and contains configuration files at the top level.
The new app files are placed in the
src/
subfolder. A corresponding end-to-end test app is placed in thee2e/
subfolder.The new app's configuration appears in the
projects
section of theangular.json
workspace configuration file, under its project name.
参数
参数 | 说明 |
---|---|
<name> | The name of the new workspace and initial project. |
选项
选项 | 说明 |
---|---|
--collection=collection | A collection of schematics to use in generating the initial app. 别名: -c |
--commit=true|false | Initial git repository commit information. 默认值: |
--createApplication=true|false | When true (the default), creates a new initial app project in the new workspace. 默认值: |
--defaults=true|false | When true, disables interactive input prompts for options with a default. 默认值: |
--directory=directory | The directory name to create the workspace in. |
--dryRun=true|false | When true, runs through and reports activity without writing out results. 默认值: 别名: -d |
--experimentalIvy=true|false | EXPERIMENTAL: When true, creates a new app that uses the Ivy rendering engine. 默认值: |
--force=true|false | When true, forces overwriting of existing files. 默认值: 别名: -f |
--help= | Shows a help message for this command in the console. 默认值: |
--inlineStyle=true|false | When true, includes styles inline in the component TS file. By default, an external styles file is created and referenced in the component TS file. 默认值: 别名: -s |
--inlineTemplate=true|false | When true, includes template inline in the component TS file. By default, an external template file is created and referenced in the component TS file. 默认值: 别名: -t |
--interactive=true|false | When false, disables interactive input prompts. 默认值: |
--minimal=true|false | When true, creates a project without any testing frameworks. 默认值: |
--newProjectRoot=newProjectRoot | The path where new projects will be created, relative to the new workspace root. 默认值: |
--prefix=prefix | The prefix to apply to generated selectors for the initial project. 默认值: 别名: -p |
--routing=true|false | When true, generates a routing module for the initial project. 默认值: |
--skipGit=true|false | When true, does not initialize a git repository. 默认值: 别名: -g |
--skipInstall=true|false | When true, does not install dependency packages. 默认值: |
--skipTests=true|false | When true, does not generate "spec.ts" test files for the new project. 默认值: 别名: -S |
--style=style | The file extension to use for style files. 默认值: |
--verbose=true|false | When true, adds more details to output logging. 默认值: 别名: -v |
--viewEncapsulation= | The view encapsulation strategy to use in the initial project. |