elevenlabs / elevenlabs-js

The official JavaScript (Node) library for ElevenLabs Text to Speech.
https://elevenlabs.io
MIT License
60 stars 7 forks source link

Errors in Nuxt web app #13

Open terrylb opened 3 months ago

terrylb commented 3 months ago

@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.

dsinghvi commented 3 months ago

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