bard-ai icon indicating copy to clipboard operation
bard-ai copied to clipboard

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

Open therealsujitk opened this issue 2 years ago • 11 comments

Prerequisites

  • [X] I have searched the issues and believe that it has not already been reported
  • [X] It occurs on the latest version of bard-ai
  • [X] I have read the FAQ and there are no solutions there

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.

therealsujitk avatar Aug 07 '23 13:08 therealsujitk

Update to 2.0.2. It was fixed.

EvanZhouDev avatar Aug 07 '23 16:08 EvanZhouDev

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

therealsujitk avatar Aug 07 '23 17:08 therealsujitk

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

EvanZhouDev avatar Aug 07 '23 17:08 EvanZhouDev

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

npm i [email protected]

therealsujitk avatar Aug 07 '23 17:08 therealsujitk

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

EvanZhouDev avatar Aug 07 '23 17:08 EvanZhouDev

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

ThatXliner avatar Aug 07 '23 22:08 ThatXliner

@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 [email protected].

therealsujitk avatar Aug 14 '23 12:08 therealsujitk

@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 [email protected].

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

rafalinliyosar avatar Aug 14 '23 16:08 rafalinliyosar

Also facing same issue

anirudhv avatar Aug 15 '23 10:08 anirudhv

same issue face in use in next js

makhdum530 avatar Nov 06 '23 05:11 makhdum530

same problem angular 17

DiegoVenancioVieira avatar Jan 14 '24 17:01 DiegoVenancioVieira