mongodb 生成NestJs项目时出现Mongoose错误

mrwjdhj3  于 2023-03-01  发布在  Go
关注(0)|答案(1)|浏览(125)

我在我的Nest项目中使用过Mongoose包,但当我尝试使用npm run build构建项目时,它会在我的控制台中抛出以下错误:

node_modules/mongoose/node_modules/mongodb/mongodb.d.ts:34:15 - error TS2305: Module '"tls"' 
has no exported member 'TLSSocketOptions'.

34 import type { TLSSocketOptions } from 'tls';

我甚至把mongoose包更新到了最新版本。然后我也得到了同样的错误:
下面是我在package.json文件中的依赖项:

"dependencies": {
    "@apollo/gateway": "^0.38.0",
    "@google-cloud/translate": "^6.2.1",
    "@nestjs/common": "^8.0.6",
    "@nestjs/core": "^8.0.6",
    "@nestjs/cqrs": "^8.0.0",
    "@nestjs/graphql": "^8.0.2",
    "@nestjs/microservices": "^8.0.6",
    "@nestjs/mongoose": "^9.0.3",
    "@nestjs/platform-express": "^8.0.6",
    "@types/luxon": "^1.15.1",
    "apollo-server-express": "^2.25.2",
    "bunyan": "^1.8.12",
    "bunyan-rotating-file-stream": "^1.6.3",
    "connect-redis": "^3.4.1",
    "consul": "^0.40.0",
    "device-detector-js": "^3.0.3",
    "elasticsearch": "^16.2.0",
    "express-session": "^1.16.2",
    "firebase-admin": "^9.4.2",
    "graphql": "^14.7.0",
    "graphql-tools": "^4.0.4",
    "json-rules-engine": "^3.1.0",
    "kafkajs": "^1.15.0",
    "lodash": "^4.17.21",
    "luxon": "^1.16.0",
    "moneysafe": "^2.2.1",
    "mongodb": "^3.5.9",
    "mongoose": "^6.3.0",
    "nestjs-i18n": "^8.1.1",
    "node-wit": "^6.0.0",
    "reflect-metadata": "^0.1.12",
    "rimraf": "^2.6.2",
    "rxjs": "^7.3.0",
    "ts-morph": "^12.0.0",
    "typescript": "^4.3.5",
    "uuid": "^3.3.2"
 },
"devDependencies": {
    "@nestjs/testing": "^5.1.0",
    "@types/jest": "^23.3.1",
    "@types/lodash": "^4.14.134",
    "@types/node": "^10.7.1",
    "@types/supertest": "^2.0.5",
    "jest": "^23.5.0",
    "nodemon": "^1.18.3",
    "prettier": "^1.14.2",
    "supertest": "^3.1.0",
    "ts-jest": "^23.1.3",
    "ts-loader": "^4.4.2",
    "ts-node": "^7.0.1",
    "tsconfig-paths": "^3.5.0",
    "tslint": "5.11.0"
}

如何解决此错误?

ryevplcw

ryevplcw1#

我通过更新@types/node到最新版本修复了这个问题。然后这个特定的错误消息就被修复了!

相关问题