命令行工具

小于 1 分钟

命令行工具

安装全局工具

npm i -g @nestjs/cli
# 帮助
 nest generate --help

一些命令

推荐用nest g resource [name]直接创建一个curd类

NameAliasDescription
appGenerate a new application within a monorepo (converting to monorepo if it's a standard structure).
librarylibGenerate a new library within a monorepo (converting to monorepo if it's a standard structure).
classclGenerate a new class.
controllercoGenerate a controller declaration.
decoratordGenerate a custom decorator.
filterfGenerate a filter declaration.
gatewaygaGenerate a gateway declaration.
guardguGenerate a guard declaration.
interfaceitfGenerate an interface.
interceptoritcGenerate an interceptor declaration.
middlewaremiGenerate a middleware declaration.
modulemoGenerate a module declaration.
pipepiGenerate a pipe declaration.
providerprGenerate a provider declaration.
resolverrGenerate a resolver declaration.
resourceresGenerate a new CRUD resource. See the CRUD (resource) generatoropen in new window for more details.
servicesGenerate a service declaration.

options

OptionDescription
--dry-runReports changes that would be made, but does not change the filesystem. Alias: -d
--project [project]Project that element should be added to. Alias: -p
--flatDo not generate a folder for the element.
--collection [collectionName]Specify schematics collection. Use package name of installed npm package containing schematic. Alias: -c
--specEnforce spec files generation (default)
--no-specDisable spec files generation