node-libs-react-native
node-libs-react-native copied to clipboard
Can't find variable: Buffer even after required 'node-libs-react-native/globals'
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: 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').
So how it resolved .
So how it resolved
add this line before everything starts.
import 'node-libs-react-native/globals