# NestJS (opens new window)

# 安装 @nestjs/cli

# 全局安装
npm i -g @nestjs/cli

提示

个人Node版本18.19.0,低版本可能会报错

  • 使用 nest --help 查看 nest 命令
  • 使用 nest new project_name 快速创建一个 nest 项目
  • 使用 nest g res module_name 快速创建一个CRUD生成器

# 加载静态资源







 



import { NestExpressApplication } from '@nestjs/platform-express'

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);
  // ...
  // 使用 useStaticAssets 加载静态资源
  app.useStaticAssets(path.resolve(__dirname, '../src/public/dist'))
}
// 这里需要注意一下 __dirname 的具体路径