serialize-javascript icon indicating copy to clipboard operation
serialize-javascript copied to clipboard

Unable to resolve module `buffer` in react-native

Open astrahov opened this issue 5 years ago • 2 comments

Packages

  • react-native: 0.63.2
  • serialize-javascript: 3.1.0 and higher (3.1.0 - 5.1.0)

Use

import serialize from 'serialize-javascript'

...

const var1 = serialize(value)

Error The application crashes on startup with an error: Unable to resolve module buffer from node_modules/safe-buffer/index.js: buffer could not be found within the project

Found a solution (in App.js): npm install -S buffer

import { Buffer } from 'buffer';
global.Buffer = Buffer; // very important

But that doesn't work either and throws another error:

  • ERROR Error: Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11
  • ERROR Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

astrahov avatar Sep 24 '20 05:09 astrahov

Packages

  • react-native: 0.66.1
  • serialize-javascript: 3.1.0 and higher (3.1.0 - 6.0.0)

There is still a problem

astrahov avatar Nov 01 '21 17:11 astrahov

Maybe the same problem:#134

cx690 avatar Nov 25 '21 10:11 cx690