node-libs-react-native icon indicating copy to clipboard operation
node-libs-react-native copied to clipboard

Can't find variable: Buffer even after required 'node-libs-react-native/globals'

Open longsangstan opened this issue 7 years ago • 3 comments

Sorry it is probably a beginner mistake. I followed the docs and required 'node-libs-react-native/globals' in my app like this:

// index.js

require('node-libs-react-native/globals');

import { AppRegistry } from 'react-native';
import App from './App';

AppRegistry.registerComponent('MyApp', () => App);

But the error of "Can't find variable: Buffer" is still showing. I added the rn-cli.config.js file already.

What am I missing? Thanks.

longsangstan avatar Feb 02 '18 10:02 longsangstan

@longsangstan: Imports get hoisted above require() calls, so try using import 'node-libs-react-native/globals' or moving everything into App.js and doing require('./App').

parshap avatar Feb 05 '18 04:02 parshap

So how it resolved .

developeromI89 avatar May 28 '21 14:05 developeromI89

So how it resolved

add this line before everything starts.

import 'node-libs-react-native/globals

quybeans avatar Jun 23 '21 10:06 quybeans