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.4.0: Cannot find name 'BufferConstructor'

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

6.4.0

Node.js version

18.3.0

MongoDB server version

N/A

Description

After upgrading to mongoose 6.4.0, Typescript projects fail to build due to missing BufferConstructor in typings

node_modules/.pnpm/mongoose@6.4.0/node_modules/mongoose/types/inferschematype.d.ts:145:33 - error TS2552: Cannot find name 'BufferConstructor'. Did you mean 'NumberConstructor'?

145           PathValueType extends BufferConstructor | 'buffer' | 'Buffer' | typeof Schema.Types.Buffer ? Buffer :
                                    ~~~~~~~~~~~~~~~~~


Found 1 error in node_modules/.pnpm/mongoose@6.4.0/node_modules/mongoose/types/inferschematype.d.ts:145

Steps to Reproduce

Upgrade to Mongoose 6.4.0 Compile typescript project

Expected Behavior

No error

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

1reaction
TomMettamcommented, Jun 21, 2022

Closing this - cause is out of date node types

Fix: npm install --save-dev @types/node@">=16.6.0"

(You should really replace >=16.6.0 with your node version)

0reactions
vkarpov15commented, Jun 25, 2022

@TomMettam no it doesn’t, Mongoose is compatible with Node versions below 16.6. This is a bug in @types/node. Further, @types/node versions don’t line up with node versions beyond major versions. So @types/node@16.6.0 is a release that attempts to be compatible with Node 16.x, but doesn’t include exactly the same changes as Node 16.6.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting error TS2304: Cannot find name 'Buffer' - Stack Overflow
I am trying to do base64 encode in NodeJS using TypeScript. Following code working fine in JavaScript. When I am writing same thing...
Read more >
Mongoose v6.8.2: API docs
If bufferCommands is true, Mongoose will throw an error after bufferTimeoutMS if the operation is still buffered. [options.dbName] «String» The name of the ......
Read more >
mongoose | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
mongoose/index.d.ts - UNPKG
152, bufferCommands?: boolean;. 153, /** The name of the database you want to use. If not provided, Mongoose uses the database name from...
Read more >
Karma npm - Vulnerabilities & Security Analysis - Snyk
Find out if karma has security vulnerabilities that can threaten your software project, ... This is a result of unobstructed use of the...
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