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

🐛 [BUG]: Module not found: Error: Can't resolve 'fs' #52

Open therealsujitk opened 1 year ago

therealsujitk commented 1 year ago

Prerequisites

Bug Description

This happens when I try to build my chrome extension that uses this package.

Module not found: Error: Can't resolve 'fs' in '/Users/sujit/Documents/My Projects/chrome-ext-litcode-solver/node_modules/bard-ai'

Reproduction Steps

  1. Create a sample application meant for the front-end (For example a website/extension).
  2. Add some bard sample code that will be executed on the front-end (This probably won't work for a website due to CORS policy, but will work for chrome extensions).
  3. fs cannot be imported because it is a server-side module, so it'll throw some kind of error.

Other information

No response

Occurance Rate

I can reproduce this bug 100% of the time.

EvanZhouDev commented 1 year ago

Update to 2.0.2. It was fixed.

therealsujitk commented 1 year ago

@EvanZhouDev are you sure? I just tested it and I still get the error.

EvanZhouDev commented 1 year ago

Are you on 2.0.2? It should be fixed in #51

therealsujitk commented 1 year ago

I am on 2.0.2, building still gives the same error.

npm i bard-ai@2.0.2
EvanZhouDev commented 1 year ago

Very strange... I'll have a look at this in a little bit

ThatXliner commented 1 year ago

May I see your code? It seems to be that you're trying to use a NodeJS-only feature in the browser. Importingbard-ai v2.0.2 seems to be fine

therealsujitk commented 1 year ago

@ThatXliner sorry for the late response, was a bit busy. This is the code that uses the bard-ai package. The build works when I comment out all of this code including the import statement. Even adding the import alone causes the build to fail with bard-ai@2.0.3.

rafalinliyosar commented 1 year ago

@ThatXliner sorry for the late response, was a bit busy. This is the code that uses the bard-ai package. The build works when I comment out all of this code including the import statement. Even adding the import alone causes the build to fail with bard-ai@2.0.3.

same issue here, creating basic code put in github page also is causing error

anirudhv commented 1 year ago

Also facing same issue

makhdum530 commented 10 months ago

same issue face in use in next js

DiegoVenancioVieira commented 8 months ago

same problem angular 17