react native中的错误unable to load script..

来源:互联网 发布:手机淘宝标准店招素材 编辑:程序博客网 时间:2024/06/18 18:35

在学习React Native的是后构建项目遇到了一个错误

unable to load script...

解决办法:

1.在项目目录/android/app/src/main下建一个文件夹assets

2.在项目目录下运行react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

3.运行react-native run-android

(

注:如果出现错误:

TransformError: D:\reactnative\Demo0\index.android.js:Unexpected token ) (While processing preset:"D:\\reactnative\\Demo0\\node_modules\\babel-preset-react-native\\index.js")

使用以下办法:

yarn remove babel-preset-react-native

yarn add babel-preset-react-native@2.1.0

然后在运行上面的代码react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res就可以了。

)

阅读全文
0 0