React-native - Install & Lauch & Filling Holes

Mitchell

Install
  • First step: install react-native:
//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:
create-react-native-app init projectName  

Lauch
  • You may have this command to launch your project:
//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:
//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:
// 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:
-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:
echo $PATH  

You will see:

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:
  • The solution:
    • reduce the version of npm
npm install npm@4 -g  

recheck the version of npm

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:
: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
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:
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  

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏技术小黑屋

Package Stopped State Since Android 3.1

Since Android 3.1, Android has introduced a LaunchControl mechanism. It’s call S...

1011
来自专栏Kubernetes

kube-controller-manager最佳配置

kubernetes version: 1.6.2 Kube-controller-manager Configuration kube-controller-...

4939
来自专栏WindCoder

Declarative Programming: Is It A Real Thing?

由于合作方希望能以英文形式发布,故以后top的译文看时间而定,没时间就不再尝试翻译(而且本来水平也不咋地),仅保留原文于此。本次是一篇关于声明式编程的讨论文章,...

891
来自专栏西二旗一哥

Clang - Use Xcode to make first Clang plugin

2395
来自专栏Golang语言社区

在GO中编写一个简单的shell

In this post, we will write a minimalistic shell for UNIX(-like) operating syste...

1355
来自专栏Golang语言社区

Go调试简单的内存泄漏

Memory leaks are a class of bugs where memory is not released even after it is n...

4863
来自专栏everhad

转载:Package by feature, not layer

The first question in building an application is "How do I divide it up into pac...

1320
来自专栏技术小黑屋

Build Android Packages From Command Line

A few months ago,I dealed with a task:To build a large amount of apk files. The...

1253
来自专栏智能计算时代

Designing your SaaS Database for Scale with Postgres

? If you’re building a SaaS application, you probably already have the notion o...

2174
来自专栏全栈架构

Spring Boot 与 Kotlin 上传文件

如果我们做一个小型的web站,而且刚好选择的kotlin 和Spring Boot技术栈,那么上传文件的必不可少了,当然,如果你做一个中大型的web站,那建议你...

1063

扫码关注云+社区

领取腾讯云代金券