elevenlabs/elevenlabs-js

Errors in Nuxt web app

terrylb opened this issue · 2 comments

@dsinghvi I'm attempting to write a simple Nuxt app to call the API but am running into errors. Does this mean it's not currently possible to use elevenlabs.js in the browser?

Errors (abbreviated for readability):

Module "child_process" has been externalized for browser compatibility. Cannot access "child_process.exec" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details. [elevenlabs.js:7204:19]

Module "fs" has been externalized for browser compatibility. Cannot access "fs.access" in client code. [elevenlabs.js:7217:19]

Module "os" has been externalized for browser compatibility. Cannot access "os.constants" in client code. [elevenlabs.js:8007:19]

Uncaught TypeError: _os.constants is undefined

From the above referenced vite.dev site:

Module externalized for browser compatibility

When you use a Node.js module in the browser, Vite will output the following warning.
Module "fs" has been externalized for browser compatibility. Cannot access "fs.readFile" in client code.
This is because Vite does not automatically polyfill Node.js modules.

We recommend avoiding Node.js modules for browser code to reduce the bundle size, although you can add polyfills manually. If the module is imported from a third-party library (that's meant to be used in the browser), it's advised to report the issue to the respective library.

@terrylb We'll get back to you here, you can expect an update to the SDK in the next ~2 weeks

@terrylb this should be fixed in the latest SDK (0.8.2), please let us know if this is still an issue