Automattic / mongoose

MongoDB object modeling designed to work in an asynchronous environment.
https://mongoosejs.com
MIT License
26.97k stars 3.84k forks source link

Property 'Buffer' does not exist on type 'typeof globalThis' on v5.13.2 #10424

Closed benpoulson closed 3 years ago

benpoulson commented 3 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

[7:08:10 PM] Starting compilation in watch mode...

node_modules/mongoose/index.d.ts:1883:33 - error TS2339: Property 'Buffer' does not exist on type 'typeof globalThis'.

1883     class Buffer extends global.Buffer {
                                     ~~~~~~

[7:08:14 PM] Found 1 error. Watching for file changes.

If the current behavior is a bug, please provide the steps to reproduce. Blank NestJS project, install mongoose as docs describe.

Followed fix on #10415, however no change.

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true
  }
}

What is the expected behavior?

No errors on TS build.

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version. NodeJS versions - v16.4.0 Linux and v12.16.1 OSX

Mongoose version - Unable to retreive from framework via console.log, but package-lock.json states: @nestjs/mongoose: 7.2.4 mongoose: 5.13.2 (depends @types/node: 15.14.1)

Attached both package.json and package-lock.json.

package.json.zip

benpoulson commented 3 years ago

Closed; My fault, for some reason @types/node 16.x doesn't work, but 15.x does.

jezsung commented 3 years ago

How do we use it with @types/node@16.0.0?

hantsy commented 3 years ago

Got the same issue here when upgrading to Node 16 API.

hantsy commented 3 years ago

OMG, the solution is downgrading @types/node, not fixing it.

vkarpov15 commented 3 years ago

We'll upgrade to @types/node@16 for Mongoose 6. I don't know of any way that Mongoose can support both @types/node@15 and @types/node@16, but PRs are most welcome if you have a suggestion.

PCOffline commented 3 years ago

Bumping this - got into the same issue

pruthviraj1991 commented 3 years ago

bumping this up, got same issue

enriqueddm commented 3 years ago

bumping this up, got same issue

vkarpov15 commented 3 years ago

Upgrade to mongoose@5.13.3 :+1: