前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >React-native - Install & Lauch & Filling Holes

React-native - Install & Lauch & Filling Holes

作者头像
Mitchell
发布2018-09-30 09:37:41
5300
发布2018-09-30 09:37:41
举报
文章被收录于专栏:西二旗一哥西二旗一哥

Mitchell

Install
  • First step: install react-native:
代码语言:javascript
复制
//Make sure you have npm, if not install it.
brew install npm  
//Install create-react-native-app
npm install -g create-react-native-app  
//Install react-native-cli
npm install -g react-native-cli  

Init
  • You can use this command as followed:
代码语言:javascript
复制
create-react-native-app init projectName  

Lauch
  • You may have this command to launch your project:
代码语言:javascript
复制
//Move into your project directory
cd projectDir  
//Launch your project
react-native run-ios  
IDE Choose
  • You can choose the IDE what you want. I use WebStorm for it's simpler and stronger. You can also use Sublime and others.

Here are some questions through I install and launch:
1.error when I launch my project
  • Question:
代码语言:javascript
复制
//The description is
21:37:47: Unable to start server  
See https://git.io/v5vcn for more information, either install watchman or run the following snippet:  
  sudo sysctl -w kern.maxfiles=5242880
  sudo sysctl -w kern.maxfilesperproc=524288
  • The solution:
代码语言:javascript
复制
// Do as the command alert
sudo sysctl -w kern.maxfiles=5242880  
sudo sysctl -w kern.maxfilesperproc=524288  
2. Mac's environment config error
  • Question:
    • While I use npm with old version I download the new one from the net again, but I have a problem with my environment as followed:
代码语言:javascript
复制
-bash: create-react-native-app: command not found
  • The solution:
    • 1.Open Terminal
    • 2.Run the command sudo nano /etc/paths
    • 3.Input your secret
    • 4.Locate to the end of the file, add your path what you want.
    • 5.Click control-x to log out
    • 6.Input "Y" to make sure to modify
  • Have a test: Open a new terminal and input:
代码语言:javascript
复制
echo $PATH  

You will see:

代码语言:javascript
复制
XXX ~ userName$ echo $PATH  
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/share/npm/bin

Reference


3.npm 5.x version is not match
  • Question:
    • As npm's update result in the version is not match, the error may as followed:
npm版本不适配.png
npm版本不适配.png
  • The solution:
    • reduce the version of npm
代码语言:javascript
复制
npm install npm@4 -g  

recheck the version of npm

代码语言:javascript
复制
npm -v  
  • The reduce will be failed if the version of npm is not change, you need to reduce the version of npm manually. You must find the directory of npm for last version and remove it and then rerun the commands above.

Link for the question for npm


4.Can't verify the install for Xcode and simulator
  • Question
    • The description is as followed:
代码语言:javascript
复制
:AwesomeProject xxx$ npm run ios

> AwesomeProject@0.1.0 ios /Users/.../Desktop/React-native/AwesomeProject
> react-native-scripts ios

下午8:20:47: Starting packager...
下午8:22:16: Starting simulator...
Unable to check Xcode version: Error: Process exited with non-zero code: 1  
下午8:22:16: Failed to start simulator:
Unable to verify Xcode and Simulator installation.  
Exiting...  
  • The solution: Open Xcode -> Preference -> Location -> Command Line Tools and check it。

5.Waiting for a longtime when you run the script
  • When I run npm run ios for many times at the beginning,I always have a long time waiting for my project to be launched when the command line is stopping at Starting simulator... as the time is frozen. So I tried to find the answer in the net and find the similar question .Three is a way using yarn to replace npm and the command is from npm run ios to yarn run ios. While when I use yarn I have some other questions:
    • Run environment error
代码语言:javascript
复制
command not found  
  • After you donwload yarn, you can see the environment it output. You can write the environment into the file as Question One mentioned and then restart it you can find everything will be ok!
  • And the time really be frozen one more time. After 5 minutes I find a application called Expo installed on my simulator.

Solution
  • End here, you finish your install for React-native Environment desciption:
代码语言:javascript
复制
xxx:~ xx$ npm -v  
4.6.1  
xxx:~ xx$ node -v  
v9.7.1  
xxx:~ xx$ react-native -v  
react-native-cli: 2.0.1  
xxx:~ xx$ yarn -v  
1.5.1  
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Install
  • Init
  • Lauch
  • IDE Choose
  • Here are some questions through I install and launch:
    • 1.error when I launch my project
      • 2. Mac's environment config error
        • 3.npm 5.x version is not match
          • 4.Can't verify the install for Xcode and simulator
            • 5.Waiting for a longtime when you run the script
              • Solution
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档