Skip to content

1.@nestjs/cli

首先全局安装 nestjs 脚手架:

shell
pnpm add @nestjs/cli --global
shell
yarn add @nestjs/cli --global
shell
npm i -g @nestjs/cli

然后使用 nest 指令初始化项目:

shell
nest new your-project-name

生成的项目目录结构大致如下:

plaintext
.
├── README.md
├── docs
│   ├── 1.install.md
│   └── index.md
├── eslint.config.mjs
├── nest-cli.json
├── package.json
├── pnpm-lock.yaml
├── src
│   ├── app.controller.spec.ts
│   ├── app.controller.ts
│   ├── app.module.ts
│   ├── app.service.ts
│   └── main.ts
├── test
│   ├── app.e2e-spec.ts
│   └── jest-e2e.json
├── tsconfig.build.json
└── tsconfig.json

2.degit

我们也可以使用degit直接拉取模板项目:

shell
degit https://github.com/nestjs/typescript-starter.git
# or
degit https://github.com/nestjs/javascript-starter.git

TIP

degitgit 区别在于,degit 命令拉取的项目不会包含 .git 历史记录