w3resource

ng new

Creates a new workspace and an initial Angular app.

ng new <name> [options]
ng n <name> [options]

Description

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.
  • By default, the files for a new initial app (with the same name as the workspace) are placed in the src/ subfolder. Corresponding end-to-end tests are placed in the e2e/ subfolder.
  • The new app's configuration appears in the projects section of the angular.json workspace configuration file, under its project name.
  • Subsequent apps that you generate in the workspace reside in the projects/ subfolder.

If you plan to have multiple apps in the workspace, you can create an empty workspace by setting the --createApplication option to false. You can then use ng generate an application to create an initial app. This allows a workspace name different from the initial app name and ensures that all apps reside in the /projects subfolder, matching the structure of the configuration file.

Arguments

ARGUMENT DESCRIPTION
<name> The name of the new workspace and initial project.

Options

OPTION DESCRIPTION
--collection=collection A collection of schematics to use in generating the initial app.
Aliases: -c
--commit=true|false Initial git repository commit information.
Default: true
--createApplication=true|false When true (the default), creates a new initial app project in the src folder of the new workspace. When false, creates an empty workspace with no initial app. You can then use the generate application command so that all apps are created in the projects folder.
Default: true .
--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.
Default: false
Aliases: -d
--enableIvy=true|false When true, creates a new app that uses the Ivy rendering engine.
Default: false
--force=true|false When true, forces overwriting of existing files.
Default: false
Aliases: -f
--help=true|false|json|JSON Shows a help message for this command in the console.
Default: false
--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.
Default: false
Aliases: -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.
Default: false
Aliases: -t
--interactive=true|false When false, disables interactive input prompts.
--minimal=true|false When true, creates a project without any testing frameworks. (Use for learning purposes only.)
Default: false
--newProjectRoot=newProjectRoot The path where new projects will be created, relative to the new workspace root.
Default: projects
--prefix=prefix The prefix to apply to generated selectors for the initial project. Default: app
Aliases: -p
--routing=true|false When true, generates a routing module for the initial project.
Default: false
--skipGit=true|false When true, does not initialize a git repository.
Default: false
Aliases: -g
--skipInstall=true|false When true, does not install dependency packages.
Default: false
--skipTests=true|false When true, does not generate "spec.ts" test files for the new project.
Default: false
Aliases: -S
--style=css|scss|sass|less|styl The file extension or preprocessor to use for style files.
Default: css
--verbose=true|false When true, adds more details to output logging.
Default: false
Aliases: -v
--viewEncapsulation=Emulated|Native|None|ShadowDom The view encapsulation strategy to use in the initial project.

Previous: ng serve
Next: ng e2e