ract-native常用命令

1.新建项目:react-native init AwesomeProject

2.运动项目

cd AwesomeProject
react-native run-ios

3.添加第三方插件:

yarn add 插件名                    // 添加插件

react-native link                              // 链接插件依赖库

react-native link 插件名                    // 链接某个插件的依赖库

或者使用:

npm install 插件名 --save

卸载模块:npm uninstall 插件名

更新模块:npm update
 4.删除node_modules 文件夹: rm -rf node_modules && npm install


 5.清楚打包缓存: rm -fr $TMPDIR/react-* or npm start -- --reset-cache

更新npm: npm install npm@latest -g

查看当前哪些包需要更新:npm outdated -g --depth=0

yarn --version
yarn init    //同npm init,执行输入信息后,会生成package.json文件
yarn config list //显示所有配置项
yarn config get <key> //显示某配置项
yarn config delete <key> //删除某配置项
yarn config set <key> <value> [-g|--global] //设置配置项
yarn install //安装package.json里所有包,并将包及它的所有依赖项保存进yarn.lock
yarn install --flat //安装一个包的单一版本
yarn install --force //强制重新下载所有包
yarn install --production //只安装dependencies里的包
yarn install --no-lockfile //不读取或生成yarn.lock
yarn install --pure-lockfile //不生成yarn.lock
yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag] //不指定依赖类型默认安装到dependencies里,你也可以指定依赖类型:
yarn add --dev/-D //加到 devDependencies
yarn add --peer/-P //加到 peerDependencies
yarn add --optional/-O //加到 optionalDependencies //默认安装包的主要版本里的最新版本,下面两个命令可以指定版本: yarn add --exact/-E //安装包的精确版本。例如
yarn add foo@1.2.3会接受1.9.1版,但是
yarn add foo@1.2.3 --exact只会接受1.2.3版
yarn add --tilde/-T //安装包的次要版本里的最新版。例如
yarn add foo@1.2.3 --tilde会接受1.2.9,但不接受1.3.0
yarn upgrade [package]
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]
yarn remove [package]
yarn cache ls //列出所有本地缓存了的包
yarn cache dir //列出本地缓存的位置
yarn cache clean //清除本地缓存
yarn check //检查package.json里的依赖版本和yarn.lock里是否一致
yarn check --integrity //检查package.json里的依赖版本的hash值和yarn.lock里是否一致,有助于验证包依赖没有更改
yarn run
yarn login/logout
yarn owner add
yarn owner rm
yarn publish
yarn version



 

posted @ 2017-10-11 09:21  浪人残风  阅读(340)  评论(0编辑  收藏  举报