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 --version

Installation

Clone Repository

git clone https://github.com/Elacity/pc2.net
cd pc2.net

Install Dependencies

npm install

Initialize Submodules

For Particle Auth wallet integration:

git submodule update --init --recursive

Build Particle Auth (Optional)

npm run build:particle-auth

Start Development Server

npm start

Your 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/                  # Documentation

Development Commands

CommandDescription
npm startStart production server
npm run devStart development server (hot reload)
npm run buildBuild frontend and backend
npm run build:frontendBuild frontend only
npm run build:backendBuild backend only

Development Mode

For active development with hot reloading:

cd pc2-node
npm run dev

This 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:backend

Configuration

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 startup

Or 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 start

Build Errors

# Clean and rebuild
rm -rf pc2-node/dist
rm -rf pc2-node/node_modules
npm install
npm run build

Submodule Issues

git submodule update --init --recursive --force

→ Ready to deploy? See VPS Deployment

© 2025 Elacity Labs. All rights reserved.