admin管理员组文章数量:1356585
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 run the android code, it raised Can't find variable: require
on the bundling phase
I uploaded my code here. Does anyone have an idea what I missed here?
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 run the android code, it raised Can't find variable: require
on the bundling phase
I uploaded my code here. Does anyone have an idea what I missed here?
Share Improve this question asked Sep 11, 2018 at 16:49 NiaNia 1311 silver badge4 bronze badges4 Answers
Reset to default 3resetting the cache worked for me.
On expo
expo r -c
for pure react native
react-native start --reset-cache
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
reseting cache worked for me as well.
I use yarn.
yarn start --reset-cache
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'
本文标签: javascriptReact Native Can39t find variable requireStack Overflow
版权声明:本文标题:javascript - React Native: Can't find variable: require - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744066740a2585139.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论