imagekit-developer / imagekit-nodejs

Node.js SDK for ImageKit.io API.
https://imagekit.io
Other
84 stars 32 forks source link

getting " imagekit_1.default is not a constructor" while using image kit in nestjs #93

Closed Ankit006 closed 7 months ago

Ankit006 commented 7 months ago

Hi, I try to use imageKit in my nestjs backend, So I had created a ImageStorageModule and ImageStorage Service

ImageStorageModule

import { Module } from '@nestjs/common';
import { ImageStorageService } from './image-storage.service';

@Module({
  providers: [ImageStorageService],
})
export class ImageStorageModule {}

and here is the ImageStorageService

import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import ImageKit from 'imagekit';
@Injectable()
export class ImageStorageService {
  constructor(private configService: ConfigService) {
    const imageKit = new ImageKit({
      publicKey: configService.get<string>('IMAGEKIT_PUBLIC_KEY'),
      privateKey: configService.get<string>('IMAGEKIT_PRIVATE_KEY'),
      urlEndpoint: configService.get<string>('IMAGEKIT_URL_ENDPOINT'),
    });
  }
}

But when I am creating an instance of ImageKit, I am getting this error "TypeError: imagekit_1.default is not a constructor"

Ankit006 commented 7 months ago

Ok, I fixed the problem. I just had to add esModuleInterop:true in the tsconfig.json.