From Source
Build and run PC2 from source code for maximum control and customization.
Prerequisites
- Node.js 20+ (23+ recommended)
- npm or yarn
- Git
Check versions:
node --version # v20.0.0 or higher
npm --version # 10.0.0 or higher
git --versionInstallation
Clone Repository
git clone https://github.com/Elacity/pc2.net
cd pc2.netInstall Dependencies
npm installInitialize Submodules
For Particle Auth wallet integration:
git submodule update --init --recursiveBuild Particle Auth (Optional)
npm run build:particle-authStart Development Server
npm startYour PC2 node is now running at http://localhost:4202
Project Structure
pc2.net/
├── src/gui/src/ # Frontend source
├── pc2-node/ # Backend source
│ ├── src/ # TypeScript source
│ │ ├── api/ # API endpoints
│ │ ├── services/ # Business logic
│ │ └── storage/ # Database & IPFS
│ ├── frontend/ # Built frontend
│ └── data/ # Runtime data
├── packages/ # Shared packages
│ └── particle-auth/ # Wallet integration
└── docs/ # DocumentationDevelopment Commands
| Command | Description |
|---|---|
npm start | Start production server |
npm run dev | Start development server (hot reload) |
npm run build | Build frontend and backend |
npm run build:frontend | Build frontend only |
npm run build:backend | Build backend only |
Development Mode
For active development with hot reloading:
cd pc2-node
npm run devThis watches for file changes and restarts automatically.
Building for Production
# Full build
npm run build
# Or step by step
cd pc2-node
npm run build:frontend
npm run build:backendConfiguration
Create or edit pc2-node/data/config/pc2.json:
{
"pc2_mode": true,
"http_port": 4200,
"accessControl": {
"enabled": false
}
}See Configuration Reference for all options.
Running as Service
For production, use PM2:
# Install PM2
npm install -g pm2
# Start with PM2
cd pc2-node
pm2 start npm --name pc2 -- start
# Save for auto-restart
pm2 save
pm2 startupOr create a systemd service (see VPS Guide).
Common Issues
Port Already in Use
# Find process using port
lsof -i :4202
# Kill it
kill -9 <PID>
# Or use different port
PORT=4300 npm startBuild Errors
# Clean and rebuild
rm -rf pc2-node/dist
rm -rf pc2-node/node_modules
npm install
npm run buildSubmodule Issues
git submodule update --init --recursive --force→ Ready to deploy? See VPS Deployment