Prerequisites
Before you begin, ensure you have the following installed:- Node.js (required) - Version 20.x (check the
.nvmrcfile) - nvm (recommended) - For managing Node.js versions
- Git - Required for cloning the repository
The project uses Node.js version 20. Using nvm is the recommended way to manage Node.js versions.
Initial Setup
Use Correct Node.js Version
If you’re using nvm to manage Node.js versions:This will automatically switch to Node.js version 20 as specified in
.nvmrc.Configure Environment Variables
Copy the example environment file and configure it:Edit
.env to add your configuration. Key variables include:.env
Available Scripts
The project includes several npm scripts for development:| Command | Description |
|---|---|
npm start | Starts the development server on port 8000 |
npm run build | Creates a production build |
npm run build:static | Creates a static export |
npm run serve | Serves the production build |
npm test | Runs linting, type checking, and tests |
npm run lint | Runs ESLint checks |
npm run lint:fix | Fixes ESLint issues automatically |
npm run format | Formats code with Prettier |
npm run type-check | Runs TypeScript type checking |
npm run set-barge-env | Sets up environment for local Barge |
Development Workflow
Code Style
The project enforces code style through ESLint and Prettier:- Git pre-commit hook - Runs Prettier on staged files (configured with Husky)
- VS Code integration - Recommended extensions for auto-formatting on save
- CI checks - Linting and type checking runs on all commits
Hot Reloading
The development server supports hot module replacement (HMR). Changes to your code will automatically refresh the browser.TypeScript Configuration
The project uses TypeScript with path aliases configured:Building for Production
Troubleshooting
Dependency Installation Issues
Peer dependency conflicts
Peer dependency conflicts
If you encounter peer dependency warnings or errors:This bypasses peer dependency conflict checks.
Node version mismatch
Node version mismatch
Ensure you’re using the correct Node.js version:
Clean installation
Clean installation
If dependencies are corrupted, perform a clean install:
Build Issues
TypeScript errors during build
TypeScript errors during build
Check for type errors without building:Fix any reported type errors before attempting to build.
Environment variable not found
Environment variable not found
Ensure your Restart the development server after modifying
.env file exists and contains all required variables:.env.Port already in use
Port already in use
If port 8000 is already in use:
Runtime Errors
Module not found errors
Module not found errors
Clear Next.js cache and rebuild:
API connection failures
API connection failures
Verify your environment variables for API endpoints:
- Check
NEXT_PUBLIC_METADATACACHE_URI - Check
NEXT_PUBLIC_SUBGRAPH_URI - Check
NEXT_PUBLIC_PROVIDER_URL
Editor Setup
VS Code (Recommended)
The project includes recommended VS Code extensions. Install them for the best development experience:- ESLint
- Prettier - Code formatter
- TypeScript Vue Plugin (Volar)
Settings
Add these settings to your VS Code workspace for auto-formatting:.vscode/settings.json
Next Steps
Barge Integration
Set up local Ocean Protocol components with Barge
Testing Guide
Learn how to write and run tests
Architecture
Understand the system architecture
Data Sources
Explore data sources and APIs