deepstream.io-client-js icon indicating copy to clipboard operation
deepstream.io-client-js copied to clipboard

Uncaught ReferenceError: Buffer is not defined

Open geohuz opened this issue 3 years ago • 5 comments

Describe the bug install the deepstreamio.client with yarn add @deepstream/client, get the following error with the new DeepstreamClient():

Uncaught ReferenceError: Buffer is not defined

geohuz avatar Aug 23 '22 06:08 geohuz

which client version? which platform (node, browser, react-native)?

jaime-ez avatar Aug 25 '22 22:08 jaime-ez

HI @jaime-ez, it's the newest client version with reactjs running on browser

geohuz avatar Aug 31 '22 12:08 geohuz

Hi, you'll have to provide an example, I can not reproduce the error. Are you using a bundler?

jaime-ez avatar Sep 01 '22 19:09 jaime-ez

Hi @jaime-ez , quote from stack overflow:

In Webpack version 5, Webpack no longer automatically polyfill's Node.js API's if they are not natively supported anymore. The browser environment does not support Buffer natively, therefore we now need to add a third party Buffer package and point Node.js to it in the Webpack config.

So I have to manually install the buffer packge then fix the issue.

geohuz avatar Sep 03 '22 04:09 geohuz

Oh ok, the you could install it per the instrucions for react native and thus change the main file to the already bundled one:

DEEPSTREAM_ENV=react-native npm install @deepstream/client --save

I'm gonna keep this open in order to remind me to document it

jaime-ez avatar Sep 05 '22 14:09 jaime-ez

Hi, this should be fixed in the latest version 7.0.1 Please reopen if problem persists

jaime-ez avatar Feb 21 '23 21:02 jaime-ez