React Native learning website and environment construction

1. Learning website

React Native Chinese website · Use React to write a framework for native applications

2. Environment setup (the setup platform for the following steps is macOS iOS)

1. Dependencies that must be installed

Node、Watchman、Xcode 和 CocoaPods。

1) Install Node

2) Install Watchman

3) Replace Taobao image

4) Install Yarn to speed up the download of node modules

5) Initialize project

6) An error is reported when initializing the project because we must use Node.js version 18 or above. The one we downloaded above is version 16.

7) Go to Node.js to check which version of Node.js is the latest version. It is best to install LTS (long-term stable support version) )

​​​​​​​

8) Install the n command globally and use the n command to update the Node.js version

9) Use the n command to install the latest Node.js (note that you need to use sudo to install)

10) Use the node -v command to check our node version and find that it is still v16

11) When using the node -v command, you may find that although we have installed node in the first step, the node command still cannot be found. In this case, you need to use brew link --overwrite node@16. Link the node command

12) As you can see from step 10, the version 20 we installed is stored in the /usr/local/bin/node directory, and the node we use is stored in /opt/homebrew/bin/node and installed The location is different, so the new version installed does not take effect. We need to replace the location vim ~/.bash_profile

13) After the replacement is completed, you need to reinstall again. Check the version to see the latest version.

14) Initialize the project again. If we install the latest version of node, we can execute the @lastest command to initialize, but we installed the stable version, so we can init directly

15) Project initialization completed

16) When running on an ios device, it should be noted that you must switch to the project directory

17) It is found that ios-deploy is not installed, execute the brew command to install it.

18) After the installation was completed, I re-ran the project and found that the error was still reported because we did not start the server.

19) Use npx react-native start command to start the server

20) After starting the project, you can run it. The results of the operation are as follows

​​​​​​​

3. Install nvm to install the specified version of node.

1. Download nvm from the terminal

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
 

2. Install the specified version

nvm install 14.20.0

3. View the current version

SF01435715MACNU:~ 01435715$ node -v
v14.20.0
SF01435715MACNU:~ 01435715$ npm -v
6.14.17
SF01435715MACNU:~ 01435715$ nvm install 14.20.0

Guess you like

Origin blog.csdn.net/qq_43658148/article/details/134889509