我在nest中创建一个控制器,这是auth.controller.ts文件。
import { Controller } from 'nestjs/common';
@Controller()
export class AppController {}
我为什么会犯这个错误?错误TS2307:找不到模块‘nestjs/ Cannot’或其对应的类型声明。
我安装了所有依赖项,删除了dist文件夹,并重新运行纱线启动:dev。
这里是我所有的依赖项。
发布于 2022-04-15 13:59:12
这个包名为@nestjs/common
,而不是nestjs/common
然后:
import { Controller } from '@nestjs/common';
提示:仔细阅读文档https://docs.nestjs.com/controllers
发布于 2022-09-05 12:41:22
如果您更正了错误,但仍然得到错误
cannot find module '@nestjs/common' or its corresponding type declarations.
那么您可能需要安装
npm install @nestjs/common
npm install @nestjs/core
对我起作用了。
https://stackoverflow.com/questions/71884228
复制相似问题