Skip to content

环境搭建

安装nest指令并用它创建应用

bash
npm add -g @nestjs/cli nodemon ts-node
nest new my-nest-app

打开编码软件

使用vscode.

安装vscode插件

  • Prisma
  • JavaScript and TypeScript Nightly
  • DotENV

prettierrc配置

NestJs项目创建后会生成.prettierrc文件,这是代码格式化规范:

json
{
  "arrowParens": "always",
  "bracketSameLine": true,
  "bracketSpacing": true,
  "embeddedLanguageFormatting": "auto",
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxSingleQuote": false,
  "printWidth": 120,
  "proseWrap": "never",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": false,
  "singleQuote": true,
  "tabWidth": 2,
  "trailingComma": "all",
  "useTabs": false,
  "vueIndentScriptAndStyle": false,
  "singleAttributePerLine": false
}

使用命令运行程序

bash
npm run start

开启监听:

bash
npm run start:dev