question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mongoose 6.1.5 typescript build fail

See original GitHub issue

Do you want to request a feature or report a bug? Bug What is the current behavior? My build is failing after updating mongoose to 6.1.5 but it was working fine in 6.1.4 If the current behavior is a bug, please provide the steps to reproduce.

https://github.com/Codversity/Codversity/runs/4710880686?check_suite_focus=true

Here’s the github action

https://github.com/Codversity/Codversity/blob/main/tsconfig.json

https://github.com/Codversity/Codversity/blob/main/tsconfig.server.json What is the expected behavior? It shouldn’t break as it’s a patch update. What are the versions of Node.js, Mongoose and MongoDB you are using? Note that “latest” is not a version. Node v16 Mongoose v6.1.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:12

github_iconTop GitHub Comments

1reaction
wejdcommented, Jan 5, 2022

@imranbarbhuiya so did that fix your issue? Was it being on a broken build that caused the problem?

In my case, it’s still failing in @types/node v17.0.5 also

node v16 test https://github.com/Codversity/Codversity/runs/4717302087?check_suite_focus=true

node v17 test https://github.com/Codversity/Codversity/runs/4717302162?check_suite_focus=true

both are failing

I checked your code and you did not fix the version of types/node you should delete the ^ before the version number

0reactions
vkarpov15commented, Jan 8, 2022

@imranbarbhuiya your build is now failing for a different reason:

./server/model/blogModel.ts:92:12
Type error: Property 'title' does not exist on type 'Document<any, any, any>'.

  90 | 
  91 | blogSchema.pre("validate", function (next) {
> 92 |   if (this.title && !this.slug) {
     |            ^
  93 |     this.slug = slugify(this.title, { lower: true, strict: true });
  94 |   } else if (this.slug) {
  95 |     this.slug = slugify(this.slug, { lower: true, strict: true });

It looks like this isn’t tied to @types/node after all, sorry for the confusion. The easiest workaround is to pass the context to pre:

blogSchema.pre<Blog>('validate', function(next) { ... })

We’ll take a look and see if we can work around this without causing significant perf overhead. I suspect the issue here is https://github.com/Automattic/mongoose/commit/1141ec487b12376b2eb7ccf0123a1f6d1245a149 .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mongoose TypeScrip cannot find name 'this'' when trying to ...
js, but I have met this issue after I install mongoose version 6.6.1 and trying to compile the project. [ ERROR ] TypeScript:...
Read more >
Migrating to Mongoose 6
See the MongoDB Node drivers' migration guide for detailed info. Below are some of the most noteworthy changes: MongoDB Driver 4.x is written...
Read more >
Mongoose - npm
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment. Mongoose supports Node.js and Deno (alpha). Build Status NPM...
Read more >
mongoose | Yarn - Package Manager
Build Status NPM version Deno version Deno popularity ... fix(query): avoid throwing circular dependency error if same object is used in multiple properties ......
Read more >
Build a REST API with Node.js, Express ... - YouTube
Build a REST API with Node.js, Express, TypeScript, MongoDB & Zod ... Node.js - TypeScript - MongoDB with Mongoose - Request validation ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found