Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error TS7016: Could not find a declaration file for module 'mongodb' #455

Open
asierbayon opened this issue May 7, 2022 · 0 comments
Open

Comments

@asierbayon
Copy link

asierbayon commented May 7, 2022

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    Express Typescript app crashes on build with the following error

node_modules/connect-mongo/build/main/lib/MongoStore.d.ts:2:83 - error TS7016: Could not find a declaration file for module 'mongodb'. '/mnt/c/Users/asier/dev/justlaunched/api/node_modules/mongodb/lib/mongodb/index.js' implicitly 
has an 'any' type.
  If the 'mongodb' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/mongodb'

import { Collection, MongoClient, MongoClientOptions, WriteConcernSettings } from 'mongodb';
  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
import expressSession from 'express-session';
import MongoStore from 'connect-mongo';

const session = expressSession({
  secret: process.env.SESSION_SECRET
  saveUninitialized: false,
  resave: false,
  cookie: {
    secure: (process.env.SESSION_SECURE && true) || false,
    httpOnly: true,
    maxAge: Number(process.env.SESSION_MAX_AGE) || 3600000
  },
  store: new MongoStore({
    ttl: Number(process.env.SESSION_MAX_AGE) || 3600,
    mongoUrl: process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017/justlaunched',
    mongoOptions: { useUnifiedTopology: true }
  })
});

export default session;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant