EvanZhouDev / bard-ai

A lightweight library to access Google Bard.
https://www.npmjs.com/package/bard-ai
GNU General Public License v3.0
117 stars 31 forks source link

fix-esm issue to use bard-ai. #55

Closed erturkdotgg closed 1 year ago

erturkdotgg commented 1 year ago

Prerequisites

Bug Description

I was using bard-ai with this instead of import: const Bard = require("fix-esm").require("bard-ai");

It was working great. But after the bard-ai v2:

It started to give this error: TypeError: Bard is not a constructor

Is it still possible for me to use it? I was be able to use it before the v2. Currently impossible for me to use import.

Reproduction Steps

Use fix-esm.

Other information

No response

Occurance Rate

I can reproduce this bug 100% of the time.

Aldhanekaa commented 1 year ago

Try to use this instead


(async function () {
  const Bard = await import('bard-ai');

that works for me for my javascript project that use require.

SouzaDevX commented 1 year ago

you need to use like this

const Bard = require('fix-esm').require('bard-ai').default;

that works