Reputation:
I import MongooseModule and use it according the documentation of NestJS and when I compile the server locally I get this error node_modules/mongoose/index.d.ts:1883:33 - error TS2339: Property 'Buffer' does not exist on type 'typeof globalThis'
. I installed @types/node
but I don't know what to do from here.
app.module.ts
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ClientsModule } from './clients/clients.module';
import { MongooseModule } from '@nestjs/mongoose';
@Module({
imports: [ClientsModule, MongooseModule.forRoot(`mongodb+srv://xxx:[email protected]/yyyyyyyy?retryWrites=true&w=majority`)],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
Upvotes: 1
Views: 712
Reputation:
I solved my problem by running npm i @types/[email protected]
. After that, I could run the server. For anyone having this issue in a near future, try both solutions from Karunakaran and mine.
Upvotes: 1
Reputation: 435
Explicitly add '@types/node' by installing types. Should be fixed in mongoose, but works as of now.
npm i --save-dev @types/node@^14.0.0
Upvotes: 1