|
| 1 | +# TLDR |
| 2 | + |
| 3 | +**Create a new Angular workspace** |
| 4 | + |
| 5 | +```ng new [my-app]``` |
| 6 | + |
| 7 | +**Create without prompts** using defaults |
| 8 | + |
| 9 | +```ng new [my-app] --defaults``` |
| 10 | + |
| 11 | +**Create with routing enabled** |
| 12 | + |
| 13 | +```ng new [my-app] --routing``` |
| 14 | + |
| 15 | +**Create with specific style format** |
| 16 | + |
| 17 | +```ng new [my-app] --style [scss|sass|less|css]``` |
| 18 | + |
| 19 | +**Create without initial git repository** |
| 20 | + |
| 21 | +```ng new [my-app] --skip-git``` |
| 22 | + |
| 23 | +**Create without installing dependencies** |
| 24 | + |
| 25 | +```ng new [my-app] --skip-install``` |
| 26 | + |
| 27 | +**Create with strict mode** for enhanced type checking |
| 28 | + |
| 29 | +```ng new [my-app] --strict``` |
| 30 | + |
| 31 | +**Create in dry-run mode** to preview changes |
| 32 | + |
| 33 | +```ng new [my-app] --dry-run``` |
| 34 | + |
| 35 | +# SYNOPSIS |
| 36 | + |
| 37 | +**ng** **new** [_name_] [_options_] |
| 38 | + |
| 39 | +# PARAMETERS |
| 40 | + |
| 41 | +_NAME_ |
| 42 | +> Name for the new workspace and initial project. |
| 43 | +
|
| 44 | +**--routing** |
| 45 | +> Generate a routing module for the initial project. |
| 46 | +
|
| 47 | +**--style** _STYLE_ |
| 48 | +> File extension for style files (css, scss, sass, less). |
| 49 | +
|
| 50 | +**--skip-git** |
| 51 | +> Do not initialize a git repository. |
| 52 | +
|
| 53 | +**--skip-install** |
| 54 | +> Do not install dependency packages. |
| 55 | +
|
| 56 | +**--skip-tests** |
| 57 | +> Do not generate spec files for the initial project. |
| 58 | +
|
| 59 | +**--strict** |
| 60 | +> Enable stricter type checking and bundle budgets. |
| 61 | +
|
| 62 | +**--defaults** |
| 63 | +> Disable interactive prompts and use default values. |
| 64 | +
|
| 65 | +**--dry-run** |
| 66 | +> Run through without making changes (preview mode). |
| 67 | +
|
| 68 | +**--prefix** _PREFIX_ |
| 69 | +> Prefix for generated selectors (default: app). |
| 70 | +
|
| 71 | +**--package-manager** _PM_ |
| 72 | +> Package manager to use (npm, yarn, pnpm, cnpm). |
| 73 | +
|
| 74 | +**--directory** _DIR_ |
| 75 | +> Directory to create the workspace in. |
| 76 | +
|
| 77 | +**--inline-style** |
| 78 | +> Include styles inline in the component TS file. |
| 79 | +
|
| 80 | +**--inline-template** |
| 81 | +> Include template inline in the component TS file. |
| 82 | +
|
| 83 | +**--view-encapsulation** _MODE_ |
| 84 | +> View encapsulation strategy (Emulated, None, ShadowDom). |
| 85 | +
|
| 86 | +**--ssr** |
| 87 | +> Configure the application for Server-Side Rendering. |
| 88 | +
|
| 89 | +**--help** |
| 90 | +> Display help information. |
| 91 | +
|
| 92 | +# DESCRIPTION |
| 93 | + |
| 94 | +**ng new** creates a new Angular workspace and generates an initial application. It scaffolds the complete project structure including configuration files, source directories, and optionally installs npm dependencies. |
| 95 | + |
| 96 | +The command sets up TypeScript configuration, Angular-specific settings in angular.json, and testing infrastructure with Karma and Jasmine. The generated workspace follows Angular best practices and conventions. |
| 97 | + |
| 98 | +When run without the **--defaults** flag, the CLI prompts for routing preferences and stylesheet format. The **--strict** option enables additional TypeScript compiler checks, stricter bundle budgets, and lint rules for improved code quality. |
| 99 | + |
| 100 | +# CAVEATS |
| 101 | + |
| 102 | +Requires Node.js and Angular CLI installed globally (**npm install -g @angular/cli**). The workspace name must be a valid npm package name (lowercase, no spaces). Creating large workspaces with full dependency installation can take several minutes depending on network speed. |
| 103 | + |
| 104 | +# HISTORY |
| 105 | + |
| 106 | +The **ng new** command has been part of **Angular CLI** since its initial release in **2016**. It evolved alongside Angular, adding options for routing in Angular 4, strict mode in Angular 10, and SSR scaffolding in Angular 17. The command generates standalone components by default since Angular 17. |
| 107 | + |
| 108 | +# SEE ALSO |
| 109 | + |
| 110 | +[ng](/man/ng)(1), [ng-generate](/man/ng-generate)(1), [ng-serve](/man/ng-serve)(1), [ng-build](/man/ng-build)(1) |
0 commit comments