简体   繁体   English

TS2614:模块没有导出成员“NextHandleFunction”

[英]TS2614: Module has no exported member 'NextHandleFunction'

Error:
node_modules/@types/body-parser/index.d.ts:14:10 - error TS2614: Module '"../../../src/connect"' has no exported member 'NextHandleFunction'. Did you mean to use 'import NextHandleFunction from "../../../src/connect"' instead?  14 import { NextHandleFunction } from 'connect';

I'm trying to use typescript into my nodejs project instead of javascript.我正在尝试在我的 nodejs 项目中使用 typescript 而不是 javascript。 I have followed a few tutorials and looked into some Github repositories, even though I'm getting this weird while compiling, but my server is getting started.我遵循了一些教程并查看了一些 Github 存储库,即使我在编译时遇到了这个奇怪的问题,但我的服务器正在启动。

import * as mongoose from 'mongoose';

type TInput = {
  db: string;
}
export default ({db}: TInput) => {
  
  const connect = () => {
    mongoose
      .connect(
        db,
        { useNewUrlParser: true }
      )
      .then(() => {
        return console.info(`Successfully connected to ${db}`);
      })
      .catch(error => {
        console.error('Error connecting to database: ', error);
        return process.exit(1);
      });
  };
  connect();

  mongoose.connection.on('disconnected', connect);
};

try this compiler option inside tsconfig.json在 tsconfig.json 中尝试这个编译器选项

  "skipLibCheck": true,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误TS2305:模块没有导出的成员 - error TS2305: Module has no exported member 错误 TS2305:模块“tls”没有导出成员“TLSSocketOptions” - error TS2305: Module '"tls"' has no exported member 'TLSSocketOptions' 模块没有导出成员“AWS” - Module has no exported member 'AWS' 错误TS2305:模块“ / node_modules / rxjs / Rx”没有导出的成员“可订阅” - error TS2305: Module “/node_modules/rxjs/Rx” has no exported member 'Subscribable' TypeScript 错误:TS2305:模块“./secretManager/secret”'没有导出成员 - TypeScript error : TS2305: Module '“./secretManager/secret”' has no exported member 打字稿错误TS2305:模块auth.service没有导出的成员'AuthService' - typescript error TS2305: Module auth.service has no exported member 'AuthService' 错误 TS2305:模块“readline”没有导出的成员“接口”。 - Firebase 功能 - error TS2305: Module '“readline”' has no exported member 'Interface'. - Firebase Functions 模块 '"rxjs"' 没有导出的成员 'firstValueFrom' - Module '"rxjs"' has no exported member 'firstValueFrom' 模块“猫鼬”没有导出成员“CreateQuery” - Module '"mongoose"' has no exported member 'CreateQuery' 模块“typeorm”没有导出成员“DataSource”和“DataSourceOptions” - Module '"typeorm"' has no exported member 'DataSource' and 'DataSourceOptions'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM