初始化一个RN项目
react-native init ReactNativeProject
初始化一个名字为ReactNativeProject的RN项目
node_modules
cd到项目的根目录,执行下列命令
npm install --force
npm cache clean && npm install
npm start --reset-cache
react-native start --reset-cache
安卓打包
cd到项目的安卓文件夹下,执行下列命令
./gradlew clean
./gradlew assembleRelease
android-start
adb reverse tcp:8081 tcp:8081 && react-native start
查看npm版本
cd到项目的根目录或者直接在命令行,执行下列命令
npm -v
查看当前的 Node 版本
node -v
查看所有全局安装的模块
直接在root根目录执行下列命令
npm list -g
React Native CLI安装
npm install -g react-native-cli
或者使用淘宝npm 镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install -g react-native-cli
利用HomeBrew安装Ruby和cocoaPods
brew install ruby
sudo gem install cocoapods
查看当前React Native的版本
react-native info

安装 release 版的应用
cd到项目的安卓文件夹下,执行下列命令
react-native run-android --variant=release
更新npm
npm install -g npm
via usb连接电脑
cd C:\Users\1\AppData\Local\Android\Sdk\platform-tools
adb reverse tcp:8081 tcp:8081
bundle-ios
react-native bundle --entry-file ./index.tsx --bundle-output ./dist/ios/index.ios.bundle --assets-dest ./dist/ios/ --dev false --platform ios
bundle-android
react-native bundle --entry-file index.js --platform android --dev false --bundle-output ./android/app/src/main/assets/index.android.bundle --assets-dest ./android/app/src/main/res/
生成的默认的package.json
npm init -y
列表清单
npm ls
find the id for the process that is listening on port 8081:
sudo lsof -i :8081
Terminating a process on port 8081
kill -9 <PID>
You can configure the bundler to use a port other than 8081 by using the port parameter:
npx react-native start --port=8088