Quick Start
This chapter will guide you through the installation and startup of comp-hub, which takes no more than 5 minutes.
Requirements
- Node.js >= 16.0.0
- npm >= 8.0.0
Supported Frameworks
| Framework | Version | Status |
|---|---|---|
| Vue | 2.x | ✅ Supported |
| Vue | 3.x | ✅ Supported |
| React | - | ⏳ Planned |
Installation
Method 1: Global Installation (Recommended)
Install comp-hub CLI globally. After installation, you can use the comphub command directly:
npm install comp-hub@latest -gMethod 2: Local Dev Dependency Installation
Install only in the current project, suitable for team collaboration scenarios:
npm install comp-hub@latest -DStart Service
Start after Global Installation
Execute in the project directory:
comphubStart after Local Installation
If you installed locally with -D, you need to execute via npx:
npx comphubAfter successful startup, the terminal will display output similar to the following:
✓ comp-hub v0.28.4
✓ Project registered (hash: 9de6965c)
██████╗ ██████╗ ███╗ ███╗ ██████╗ ██╗ ██╗ ██╗ ██╗ ██████╗
██╔════╝ ██╔═══██╗ ████╗ ████║ ██╔══██╗ ██║ ██║ ██║ ██║ ██╔══██╗
██║ ██║ ██║ ██╔████╔██║ ██████╔╝ ███████║ ██║ ██║ ██████╔╝
██║ ██║ ██║ ██║╚██╔╝██║ ██╔═══╝ ██╔══██║ ██║ ██║ ██╔══██╗
╚██████╗ ╚██████╔╝ ██║ ╚═╝ ██║ ██║ ██║ ██║ ╚██████╔╝ ██████╔╝
╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝
Version 0.28.4
Project /home/user/projects/housing/vue2
Hash 9de6965c
Port 5478
URL http://localhost:5478/9de6965c/main/
─────────────────────────────────────────────
comphub status View all projects
comphub stop 9de6965c Stop current project
comphub stop --all Stop all projects
comphub kill Shutdown masterUse a browser to access the displayed URL to enter the comp-hub platform.
CLI Command Line Parameters
You can also configure startup options via command line parameters:
comphub [options]Parameter Description:
| Parameter | Short | Type | Default | Description |
|---|---|---|---|---|
--port | -p | number | 5478 | Service port |
--dir | -d | path | "./" | Resource directory relative path |
| --version | -v | - | - | Show version number | | --help | -h | - | - | Show help information |
Usage Examples:
# Start with specified port
comphub -p 8080
# Specify resource directory
comphub -d ./src
# View version number
comphub -v
# View help information
comphub -hConfiguration
To specify the component directory or configure custom proxy rules, create a .comphub.json or .comphub.js file in the project root directory:
Configuration File Format
JSON Format (.comphub.json):
{
"dir": "./src",
"allowDebug": false
}JS Format (.comphub.js):
module.exports = {
dir: './src',
allowDebug: false
}Configuration Items
| Configuration Item | Type | Default | Description |
|---|---|---|---|
dir | string | "./" | Relative path to the component code root directory. Only this directory and its subdirectories can be operated during upload/download |
allowDebug | boolean | false | Whether to allow debug mode |
proxy | object | - | Custom proxy rules, same format as http-proxy-middleware options |
Configuration File Loading Priority
- Try to load
.comphub.jsonfirst - If the JSON file does not exist, try to load
.comphub.js - If neither exists, use default configuration
Configuration Priority
Configuration value priority from high to low:
- Command line parameters (e.g.,
-d ./src) - Configuration file (
.comphub.jsonor.comphub.js) - Default configuration
Next Steps
After the service starts, you can:
- Upload Component — Publish your components to the platform
- Preview & Download — View and use components from others