简体   繁体   English

为什么我收到此错误找不到模块“nestjs/common”或其相应的类型声明

[英]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.这是我所有的依赖项。

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.

相关问题 找不到模块“graphql-hooks”或其相应的类型声明 - Cannot find module 'graphql-hooks' or its corresponding type declarations 找不到模块“./App.svelte”或其对应的类型声明 - Cannot find module './App.svelte' or its corresponding type declarations 如何解决找不到找不到模块'../home/featuredRooms'或其对应的类型声明。? - how to solve cannot find Cannot find module '../home/featuredRooms' or its corresponding type declarations.? React,Storybook - TS2307:找不到模块“按钮”或其相应的类型声明 CAN SB RESOLVE? - React,Storybook - TS2307: Cannot find module 'Button' or its corresponding type declarations CAN SB RESOLVE? 找不到模块“@react-navigation/native”或其相应的类型声明 - Cannot find module '@react-navigation/native' or its corresponding type declarations Docker/Next js:: 找不到模块“@mui/x-date-pickers/AdapterDateFns”或其相应的类型声明 - Docker/Next js :: Cannot find module '@mui/x-date-pickers/AdapterDateFns' or its corresponding type declarations VueJS/Typescript - 找不到模块“./components/Navigation”或其相应的类型声明 - VueJS/Typescript - Cannot find module './components/Navigation' or its corresponding type declarations ReScript,TypeScript:找不到模块“@rescript/react/src/ReactDOM.gen”或其相应的类型声明 - ReScript, TypeScript: Cannot find module '@rescript/react/src/ReactDOM.gen' or its corresponding type declarations 在 vercel 上部署我的 next.js 项目,找不到模块“react-icons/Fa”或其相应的类型声明 - deploy my next.js project on vercel, Cannot find module 'react-icons/Fa' or its corresponding type declarations React Native Typescript babel-plugin-module-resolver 错误:找不到模块或其对应的类型声明 - React Native Typescript babel-plugin-module-resolver error: Cannot find module or its corresponding type declerations
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM