Skip to content Skip to sidebar Skip to footer

React Native: Can't Find Variable: Require

I am trying to modify a react native boilerplate so that I can be run on Android platform. I installed the expo package and added an index.js file on the root directory. But when I

Solution 1:

resetting the cache worked for me.

On expo

expo r -c

for pure react native

react-native start --reset-cache

Solution 2:

For those whose cache clearing didn't work. Try deleting .bablerc file. It has its own ways of effecting cache. My issue was only resolved after i deleted this. I came across this when i was porting my react native app to web using react-native-web .

Platforms:

expo react native react native web

Solution 3:

You should import your server.default in es6 style. require is a node.js method, in es6 modules you should use import instead. See here for more info on the usage of import.

Here you did

const newApp = require('./server').default;

When you should have

import {default} from'./server'

Post a Comment for "React Native: Can't Find Variable: Require"