Repository: promptfoo/promptfoo
Issue: Can't import the npm package in my React app
Root cause: Environment Incompatibility

I want to be able to use promptfoo in my simple React app created with the create-react-app command but I have these errors :

```
Compiled with problems:
×
ERROR in ./node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js 69:35-57
Module not found: Error: Can't resolve 'fs/promises' in 'C:\Users\XXX\Desktop\Projects\sbs-prompt-testing\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\resolvers'
ERROR in ./node_modules/@apidevtools/json-schema-ref-parser/dist/lib/util/url.js 12:15-30
Module not found: Error: Can't resolve 'path' in 'C:\Users\XXX\Desktop\Projects\sbs-prompt-testing\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\util'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
	- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "path": false }
ERROR in ./node_modules/@colors/colors/lib/colors.js 34:11-26
Module not found: Error: Can't resolve 'util' in 'C:\Users\XXX\Desktop\Projects\sbs-prompt-testing\node_modules\@colors\colors\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
	- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "util": false }
```

And it keeps going on forever.
The issue happens when I import the package with : `import promptfoo from 'promptfoo';`
Do you have any idea why ?

```
promptfoo.js?v=6a26bb7a:638 Uncaught ReferenceError: global is not defined
    at node_modules/lodash-node/modern/support.js (promptfoo.js?v=6a26bb7a:638:36)
    at __require2 (chunk-7REXU52E.js?v=6a26bb7a:19:50)
    at node_modules/lodash-node/modern/internals/baseCreateCallback.js (promptfoo.js?v=6a26bb7a:652:19)
    at __require2 (chunk-7REXU52E.js?v=6a26bb7a:19:50)
    at node_modules/lodash-node/modern/functions/createCallback.js (promptfoo.js?v=6a26bb7a:946:30)
    at __require2 (chunk-7REXU52E.js?v=6a26bb7a:19:50)
    at node_modules/lodash-node/modern/arrays/rest.js (promptfoo.js?v=6a26bb7a:983:26)
    at __require2 (chunk-7REXU52E.js?v=6a26bb7a:19:50)
    at node_modules/lodash-node/modern/arrays.js (promptfoo.js?v=6a26bb7a:1607:15)
    at __require2 (chunk-7REXU52E.js?v=6a26bb7a:19:50)
```

Same with Vue/Vite.

```
./node_modules/@apidevtools/json-schema-ref-parser/dist/lib/resolvers/file.js:38:0
Module not found: Can't resolve 'fs/promises'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/@apidevtools/json-schema-ref-parser/dist/lib/options.js
./node_modules/@apidevtools/json-schema-ref-parser/dist/lib/normalize-args.js
./node_modules/@apidevtools/json-schema-ref-parser/dist/lib/index.js
./node_modules/promptfoo/dist/src/util.js
./node_modules/promptfoo/dist/src/index.js
./src/app/components/TestingSection.js
./src/app/page.js
```

Same with NextJS

It looks like you're trying to use promptfoo in the browser and bundle it on the client with webpack, but browser usage is not supported.  promptfoo is used as a CLI or a node package.

You could try using polyfills or mocking npm modules such as fs, path, util, but that is not something I've tried.