GraphQLGuide / apollo-datasource-mongodb

Apollo data source for MongoDB
MIT License
285 stars 64 forks source link

(BUG) Cannot find module 'mongoose' or its corresponding type declarations. #87

Closed jake-ruth-qm closed 2 years ago

jake-ruth-qm commented 2 years ago

When trying to compile typescript, I get this error:

Cannot find module 'mongoose' or its corresponding type declarations.

I tried rm -rf node_modules, package-lock.json, as well clean installing with yarn to see if that fixed it but no luck.

For now, I am just adding mongoose as a dev dep in my root package.json but I'd like if there is a solution for this.

I'm using the latest version (0.5.2) and tried downgrading as well. Still no luck.

aymswick commented 2 years ago

Bumping here as I ran into the issue as well, is this project still maintained? It seems mongoose should either be added to the package dependencies or the import removed

lorensr commented 2 years ago

Thanks for reporting! Seems a shame to move from devDep to dep for a compile-time thing, but I don't know of a better solution. Should be fixed in 0.5.3.

I don't have much time these days, but intend to continue reviewing PRs.

crccheck commented 2 years ago

hah, of course you can't have it both ways. I found that 0.5.3 is introducing a second vestigial mongoose@^5.13.8 dependency in my package in addition to my mongoose@6.2.9. I abandoned TypeScript so I don't have a solution for the original problem. Perhaps a peer dependency or optional dependency instead?

tubbo commented 2 years ago

@lorensr I'm also having problems upgrading to the latest patch release, it broke my TypeScript build because it's trying to install a higher version of Mongoose. Since Mongoose isn't actually used in the implementation code, I'm not sure why it was added to dependencies. I can see it being used in tests, but those files aren't included into the build so I'm not sure why this was considered a "bug". It seems to be unrelated to the packaged code from apollo-datasource-mongodb.

lorensr commented 2 years ago

Makes sense, sorry about that! Moved it to a peer dep in 0.5.4—does that work for you?