RN 学习笔记

来源:互联网 发布:移动网络机顶盒遥控器 编辑:程序博客网 时间:2024/06/03 18:06

下载项目至本机

git clone https://github.com/henter/ReactNativeRubyChina.gitcd ReactNativeRubyChina

查看版本

react-native -v

如果版本过低会出现如下提示

D:\study\react\reactjs\demo>react-native -vreact-native-cli: 2.0.1react-native: n/a - not inside a React Native project directory

表示RN版本过低

强制更新并补充package.json

查看默认package.json

{  "name": "RubyChina",  "version": "0.0.1",  "private": true,  "scripts": {   "start": "node_modules/react-native/packager/packager.sh"  },  "dependencies": {  "react-native": "^0.19.0",  "react-native-code-push": "^1.5.3-beta"  }}

信息不足

npm init --force

执行上述指令后,如果package.json中信息充分,会补充确实的部分.

错误提示

npm WARN react-native@0.32.0 requires a peer of react@~15.3.0 but none is installed

表示react@15.3.0没有安装
解决
删除工程目录下的依赖node_modules文件夹
同时指定react 和 react-native 版本并锁定

npm install --save react-native@0.32.0 react@15.3.0PS D:\ReactNativeRubyChina> npm install --save react-native@0.32.0 react@15.3.0>spawn-sync@1.0.15 postinstall >D:\ReactNativeRubyChina\node_modules\spawn-syncnode postinstall+react-native@0.32.0+react@15.3.0
原创粉丝点击