React Native Expo Navigation
npx create-expo-app --template
is a command for quickly creating an Expo application. It helps you create a new project and select a template to initialize the project. This command has pre-installed some common dependencies and configurations, so you don't need to manually run npx expo install
to install additional packages.
Detailed steps and explanations
-
Install Node.js and npm First, you need to make sure you have installed Node.js and npm (Node.js package manager). You can check if it is installed with the following command:
node -v
npm -v
If not installed, visit the Node.js official website to install it.
- Install Expo CLI (if not installed) Expo CLI is a tool for creating and managing Expo applications. If you don't have Expo CLI installed yet, you can install it through npm using the following command:
npm install -g expo-cli
This will install Expo CLI globally, allowing you to run Expo commands in the command line.
- Create a new Expo application Use the
npx create-expo-app
command to create a new Expo application. You can choose a template to initialize the project. If you don't specify a template, a basic Expo application will be created by default.
Run the following command:
npx create-expo-app MyNewApp --template
Here, MyNewApp
is the name of your new app. You can change it to whatever you like.
- Choose a template When you execute
npx create-expo-app MyNewApp --template
, the command will create a new folderMyNewApp
and initialize an Expo project. Expo provides several templates that you can choose from:
-
blank
: A blank template suitable for building an app from scratch. -
tabs
: A template with tab navigation, suitable for multi-page apps. -
stack
: A template with stack navigation, suitable for apps with a navigation stack.
If you want to choose a specific template, such as a template with tab navigation, you can run the following command:
npx create-expo-app MyNewApp --template tabs
This will create an app template with tabbed navigation.
- Enter the project directory After creating the app, enter your project directory:
cd MyNewApp
-
Start the Expo development server In the project directory, you can start the Expo development server with the following command:
npm start
或者:
expo start
This will start the Expo development server and open a browser window showing your app. You can use the Expo Go app to scan the QR code on your phone to preview the app, or view it in the browser.