简介
Nest.js:用于构建高效且可伸缩的服务端应用程序的渐进式 Node.js
框架。
在底层,Nest
使用强大的 HTTP Server
框架,如:Express
(默认)和 Fastify
。
前置
Node.js(>= 10.13.0)
node -v
# v12.14.1
npm -v
# 6.13.4
安装
- 使用
Nest CLI
构建项目
# npm
npm i -g @nestjs/cli
# yarn
yarn global add @nestjs/cli
nest new project-nest
- 使用
Git
克隆项目
# TypeScript
git clone https://github.com/nestjs/typescript-starter.git project-nest
# JavaScript
git clone https://github.com/nestjs/javascript-starter.git project-nest
cd project-nest
npm install
# npm
npm run start
# yarn
yarn run start
- 手动创建
# 通过使用 npm 或 yarn 安装核心和支持文件,从头开始手动创建项目,自主负责创建项目样板文件。
npm i --save @nestjs/core @nestjs/common rxjs reflect-metadata
运行
cd project-nest
# npm
npm run start
# yarn
yarn run start