[英]Why I got this error Cannot find module 'nestjs/common' or its corresponding type declarations
I am creating a controller in nest js this is file auth.controller.ts我正在嵌套 js 中创建 controller 这是文件 auth.controller.ts
import { Controller } from 'nestjs/common';
@Controller()
export class AppController {}
Why I get this error?为什么我会收到此错误? error TS2307: Cannot find module 'nestjs/common' or its corresponding type declarations.
错误 TS2307:找不到模块“nestjs/common”或其相应的类型声明。
I installed all dependencies, deleted the dist folder, and rerun yarn start:dev.我安装了所有依赖项,删除了 dist 文件夹,然后重新运行 yarn start:dev。
Here is all my dependencies.这是我所有的依赖项。
The package is called @nestjs/common
, not nestjs/common
package 被称为
@nestjs/common
,而不是nestjs/common
Then:然后:
import { Controller } from '@nestjs/common';
tip: read the docs carefully https://docs.nestjs.com/controllers提示:仔细阅读文档https://docs.nestjs.com/controllers
If you corrected the typo but you are still getting the error如果您更正了错字,但您仍然收到错误
cannot find module '@nestjs/common' or its corresponding type declarations.
Then you may need to install然后你可能需要安装
npm install @nestjs/common
npm install @nestjs/core
It worked for me.它对我有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.