Skip to content

Development Environment Setup

This guide provides detailed instructions on how to set up a uni-app development environment, including development tools installation and configuration.

Development Tool Selection

💡 Recommended: Use HBuilderX as Development Tool

HBuilderX is an IDE designed specifically for uni-app by DCloud, providing rich visual operations and debugging features.

Development Tools Comparison

Development ToolAdvantagesDisadvantagesSuitable For
HBuilderXBuilt-in uni-app support, visual operations, convenient debugging, fast executionSome advanced features require paymentAll developers, especially beginners
VS Code + PluginsRich ecosystem, strong extensibility, high customizationRequires additional configuration, debugging not as convenient as HBuilderXDevelopers with VS Code experience
Command Line + EditorHigh flexibility, suitable for automation workflowsHigh learning curve, requires more configurationDevelopers with extensive development experience

HBuilderX Installation and Configuration

Download and Installation

Follow these steps to install HBuilderX:

  1. Visit Official Website - Go to https://www.dcloud.io/hbuilderx.html
  2. Select Version - Recommended to download App Development Edition, supports uni-app development
  3. Install Software - Double-click the installation package after download

Version Selection

Version TypeFeaturesUse CaseRecommendation
Standard EditionLightweight editor, suitable for Web developmentWeb project development⭐⭐⭐
App Development Edition 🌟Integrated App development environment, supports uni-appuni-app project development⭐⭐⭐⭐⭐

Plugin Installation

HBuilderX extends functionality through plugins. The following plugins are needed for uni-app development:

Essential Plugins

  • uni-app Compilation - Essential plugin for uni-app
  • App Real Device Running - For App development and debugging
  • 🌐 Built-in Browser - For H5 preview
  • 🎨 scss/sass Compilation - For style development
  • 📝 eslint-js - Code standard checking
  • prettier - Code formatting

Development Environment Configuration

Editor Settings

  1. Open HBuilderX, click menu Tools -> Settings
  2. Configure editor font, theme, indentation, etc.
  3. Recommended to enable "Auto format on save" option

Runtime Environment Configuration

  1. Click menu Tools -> Settings -> Run Configuration
  2. Configure browser path, simulator path, etc.
  3. Set default runtime environment

Git Configuration

  1. Click menu Tools -> Settings -> Git Configuration
  2. Set Git path and user information
  3. Enable Git integration features

Command Line Tools Installation

If you prefer command line development, follow these steps to install uni-app command line tools:

Install Node.js

Step 1: Download Node.js

Visit Node.js Official Website to download the Long Term Support (LTS) version

Step 2: Install Node.js

Double-click the installation package and follow the prompts to complete installation

Step 3: Verify Installation

Open command line tool and enter the following commands to check if installation was successful:

bash
node -v
npm -v

Install Vue CLI

bash
# Install Vue CLI globally
npm install -g @vue/cli

# Verify installation
vue --version

Install uni-app Template

bash
# Create uni-app project
vue create -p dcloudio/uni-preset-vue my-project

# Select template type
# Choose default template (Vue2) or Vue3/TypeScript template

Development Environment Requirements

System Requirements

ItemRequirement
Operating SystemWindows 7 and above / macOS 10.13 and above / Linux
MemoryRecommended 8GB and above
Storage SpaceAt least 10GB available space
Node.js Version12.0.0 and above

Simulator Installation

Android Simulator

Android Studio Simulator

  1. Download and install Android Studio
  2. Open Android Studio, click Tools -> AVD Manager
  3. Click Create Virtual Device, select device model and system version
  4. After creation, you can select this simulator in HBuilderX to run projects

iOS Simulator (macOS Only)

  1. Download and install Xcode
  2. Open Xcode, click Xcode -> Preferences -> Components
  3. Download required iOS simulator versions
  4. You can select iOS simulator in HBuilderX to run projects

Real Device Debugging Configuration

Android Real Device Debugging

  1. Enable USB Debugging - Find Developer Options in phone settings and enable USB debugging
  2. Install Drivers - Ensure computer has installed USB drivers for the corresponding phone brand
  3. Connect Device - Use USB cable to connect phone and computer
  4. Run Project - Select the connected device in HBuilderX to run project

iOS Real Device Debugging

⚠️ Note: iOS real device debugging requires Apple Developer Account

iOS real device debugging requires Apple Developer Account and certificate configuration. Personal development can use free developer account, but with some limitations.

  1. Register Developer Account - Visit Apple Developer website to register account
  2. Install Xcode - Install Xcode on Mac computer
  3. Configure Certificates - Configure development certificates and provisioning profiles in Xcode
  4. Connect Device - Use USB cable to connect iPhone and Mac computer
  5. Run Project - Select the connected device in HBuilderX to run project

Common Issues

HBuilderX Cannot Start

Solutions:

  1. Check if antivirus software is blocking
  2. Try running as administrator
  3. Re-download and install the latest version

Plugin Installation Failed

Solutions:

  1. Check network connection
  2. Try switching plugin server
  3. Close HBuilderX and reopen, then install again

Real Device Debugging Connection Failed

Solutions:

  1. Check if USB cable is working properly
  2. Confirm phone has USB debugging enabled
  3. Reinstall phone drivers
  4. Try restarting phone and computer

Next Steps

After completing development environment setup, you can continue learning:

Learning ContentDescriptionLink
Project Structure DetailsDeep dive into uni-app project file structureView Details
LifecycleLearn about uni-app application and page lifecycleView Details
Basic ComponentsUnderstand how to use uni-app basic componentsView Details

Related Links:

一次开发,多端部署 - 让跨平台开发更简单