This guide will help you get started with Cocos CLI, from installation to basic usage.
- Node.js 22.17.0 or higher
- Git
# Clone repository
git clone <repository-url>
cd cocos-cli
# Install dependencies
npm run init
npm install
# Download development tools (first time only)
npm run download-tools
# Build and link globally
npm run build
npm link# Check if command is available
cocos --help
cocos --version# Create new Cocos project
cocos create --project ./my-game
# Specify project type (default: 3d)
cocos create --project ./my-game --type 2d# Build to Web Mobile platform
cocos build --project ./my-game --platform web-mobile
# Debug mode build
cocos build --project ./my-game --platform web-mobile --debugUse the interactive wizard to easily complete various operations:
# Start wizard
cocos wizardThe wizard will guide you through:
- Project building
- Starting MCP server
- Viewing help information
Start MCP server to support AI tool integration:
# Start MCP server
cocos start-mcp-server --project ./my-game --port 9527Use in CI environments or automated scripts:
cocos --no-interactive build --project ./my-gameGet detailed execution information:
cocos --debug build --project ./my-game# Check global link
npm list -g --depth=0
# Re-link
npm unlink -g cocos-cli
npm link# Clean and rebuild
npm run build:clear
npm run build- Use absolute paths
- Ensure project directory exists and is accessible
- Check if project contains necessary configuration files
- View Commands Documentation to learn all available commands
- Read API Documentation to understand configuration options
- Check Tool Download Guide to learn about development tools
# Display help information
cocos --help
# Display help for specific command
cocos build --help
cocos create --help