react-native 下载的项目怎么run起来

1.第一步 (如果出错权限问题,sudo + npm(下面命令行))
npm install -g React -native-cli (安装全局的好了之后react-native upgrade这个命令可以运行)命令行工具
2.安装

npm install

建议:慢的时候用下面的

npm install -g --registry=https://registry.npm.taobao.org

3.更新

react-native upgrade (然后要替换的时候输入y,不需要替换的则输入n)

4.启动

React-native start

5.运行(新开一个终端运行 测试 下)
npm test

如果安装过程发现有不对劲的地方,建议步骤:

假如npm最高是5.0版本,react-native最高是0.44版本

1、npm -v和 react-native -v 查看版本,如果不出现版本,就说明相应的npm和react-native没有安装好.

2、安装比最高版本低一个大版本最好,因为最新的版本可能各种问题,react-native目前还没有出大版本,所以不稳定因素太多,如下:

npm uninstall npm@5.0.0 npm uninstall react-native@0.44.0 卸载高版本

npm install npm@4.0.0 npm install --save react-native@0.34.0 安装低一个大版本

如果react-native upgrade不能跑起来,就使用npm install -g react-native-cli

出现的问题:

1、deprecated node-uuid@1.4.7: use uuid module instead”

npm uninstall --save node-uuid
npm install --save uuid

2、react-native@0.34.0 requires a peer of react@~15.3.1 but none was installed.

npm install --save react@~15.3.1

3、npmWARNdeprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue

npm install --save minimatch@3.0.2

4、Undefined symbols for architecture x86_64:

"std::__1::basic_string<char,std::__1::char_traits<char>,std::__1::allocator<char> >::__init(char const*,unsigned long)",referenced from:

_main in main.o

"std::__1::basic_string<char,std::__1::allocator<char> >::~basic_string()",referenced from:

_main in main.o

"std::terminate()",referenced from:

___clang_call_terminate in main.o

"___cxa_begin_catch",referenced from:

___clang_call_terminate in main.o

"___gxx_personality_v0",referenced from:

_main in main.o

Dwarf Exception Unwind Info (__eh_frame) in main.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [main] Error 1


想了很多办法,终于看到有人提示:编译选项添加-lstdc++,即使用标准C++库,问题解决!

5、

解决办法:找到相应的App.js只能对外导出一个组件,也就是App.js 中组件export了两次
6、
问题原因:找不到组件
解决办法:有yarn
watchman watch-del-all
rm -rf ./node_modules
npm cache clean
yarn cache clean
rm -rf $TMPDIR/react-*
yarn install
npm cache clean
yarn cache clean
yarn add uuid
没有yarn:
watchman watch-del-all
rm -rf ./node_modules
npm cache clean
rm -rf $TMPDIR/react-*
npm install
npm cache clean
npm install uuid

相关文章

react 中的高阶组件主要是对于 hooks 之前的类组件来说的,如...
我们上一节了解了组件的更新机制,但是只是停留在表层上,例...
我们上一节了解了 react 的虚拟 dom 的格式,如何把虚拟 dom...
react 本身提供了克隆组件的方法,但是平时开发中可能很少使...
mobx 是一个简单可扩展的状态管理库,中文官网链接。小编在接...
我们在平常的开发中不可避免的会有很多列表渲染逻辑,在 pc ...