Home > Enterprise >  error TS2305: Module '"tls"' has no exported member 'TLSSocketOptions'
error TS2305: Module '"tls"' has no exported member 'TLSSocketOptions'

Time:11-07

I'm trying to connect to MongoDB using the MongoDB drivers in a Node.js project but am having issues compiling, and receive the titular error "node_modules/mongodb/mongodb.ts34.d.ts:31:10 - error TS2305: Module '"tls"' has no exported member 'TLSSocketOptions'." Any help for how to resolve this apparent node package issue would be very helpful!

When I inspect, the tls package it has TLSSocketOptions and appears to have it exported through the following at the end of the file

declare module 'node:tls' {
    export * from 'tls';
}

My package.json

{
  "main": "wwwroot/index.js",
  "bin": "wwwroot/index.js",
  "scripts": {
    "start": "node ./wwwroot/index.js",
    "dev": "ts-node src/",
    "compile": "npx tsc",
    "postinstall": "npx tsc"
  },
  "engines": {
    "node": "14.18.1"
  },
  "dependencies": {
    "@discordjs/uws": "^10.149.0",
    "discord.js": "^11.4.2",
    "mongodb": "^4.1.4",
    "snoowrap": "^1.23.0"
  },
  "devDependencies": {
    "@types/node": "^11.15.54",
    "pkg": "^4.5.1",
    "ts-node": "^10.4.0",
    "tslint": "^5.16.0",
    "typescript": "^3.9.10"
  }
}

CodePudding user response:

Your version of @types/node seems to be ancient and I guess the export in question was added since then

  • Related