0
# Project Creation
1
2
Create new NestJS applications with comprehensive customization options including language selection, package manager choice, and project structure configuration.
3
4
## Capabilities
5
6
### New Command
7
8
Creates a new NestJS application with the specified name and configuration options.
9
10
```bash { .api }
11
# Create new application
12
nest new [name] [options]
13
nest n [name] [options]
14
15
# Options:
16
--directory [directory] # Specify the destination directory
17
-d, --dry-run # Report actions without writing results (default: false)
18
-g, --skip-git # Skip git repository initialization (default: false)
19
-s, --skip-install # Skip package installation (default: false)
20
-p, --package-manager [manager] # Specify package manager (npm, yarn, pnpm)
21
-l, --language [language] # Programming language (TypeScript, JavaScript, ts, js)
22
-c, --collection [collectionName] # Schematics collection to use (default: @nestjs/schematics)
23
--strict # Enable strict mode in TypeScript (default: false)
24
```
25
26
**Usage Examples:**
27
28
```bash
29
# Create a new app with default settings
30
nest new my-app
31
32
# Create app with custom directory
33
nest new my-app --directory ./projects
34
35
# Create JavaScript project with yarn
36
nest new my-app --language javascript --package-manager yarn
37
38
# Create project without git initialization
39
nest new my-app --skip-git
40
41
# Create project and skip package installation
42
nest new my-app --skip-install
43
44
# Create project with strict TypeScript mode
45
nest new my-app --strict
46
47
# Dry run to see what would be created
48
nest new my-app --dry-run
49
```
50
51
### Language Options
52
53
Specify the programming language for your new project.
54
55
```bash { .api }
56
# TypeScript (default)
57
-l typescript
58
-l ts
59
60
# JavaScript
61
-l javascript
62
-l js
63
```
64
65
### Package Manager Options
66
67
Choose your preferred package manager for dependency management.
68
69
```bash { .api }
70
# NPM (default)
71
-p npm
72
73
# Yarn
74
-p yarn
75
76
# PNPM
77
-p pnpm
78
```
79
80
### Directory Structure
81
82
When creating a new project, the CLI generates the following structure:
83
84
```
85
my-app/
86
├── src/
87
│ ├── app.controller.spec.ts
88
│ ├── app.controller.ts
89
│ ├── app.module.ts
90
│ ├── app.service.ts
91
│ └── main.ts
92
├── test/
93
│ ├── app.e2e-spec.ts
94
│ └── jest-e2e.json
95
├── nest-cli.json
96
├── package.json
97
├── README.md
98
├── tsconfig.build.json
99
└── tsconfig.json
100
```
101
102
### Schematics Collection
103
104
Specify which schematics collection to use for project generation.
105
106
```bash { .api }
107
# Default NestJS schematics
108
-c @nestjs/schematics
109
110
# Custom schematics collection
111
-c my-custom-schematics
112
```
113
114
## Configuration Files Generated
115
116
### nest-cli.json
117
118
Project configuration file defining build settings and project structure:
119
120
```json
121
{
122
"collection": "@nestjs/schematics",
123
"sourceRoot": "src"
124
}
125
```
126
127
### package.json Scripts
128
129
The generated package.json includes common development scripts:
130
131
```json
132
{
133
"scripts": {
134
"build": "nest build",
135
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
136
"start": "nest start",
137
"start:dev": "nest start --watch",
138
"start:debug": "nest start --debug --watch",
139
"start:prod": "node dist/main",
140
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
141
"test": "jest",
142
"test:watch": "jest --watch",
143
"test:cov": "jest --coverage",
144
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
145
"test:e2e": "jest --config ./test/jest-e2e.json"
146
}
147
}
148
```
149
150
## Error Handling
151
152
The command validates language options and will throw an error for invalid languages:
153
154
```bash
155
# This will fail
156
nest new my-app --language python
157
# Error: Invalid language "python" selected. Available languages are "typescript" or "javascript"
158
```