Fix version mismatch errors
Learn how to resolve version compatibility issues between Midnight components that cause build failures and runtime errors.
Understanding version mismatchesβ
Midnight consists of multiple components that must work together in compatible versions:
- Compact compiler
- Runtime libraries (
@midnight-ntwrk/compact-runtime,@midnight-ntwrk/ledger, etc.) - Proof server
- Indexer (if used)
When these components are out of sync, you may encounter build errors, deployment failures, or runtime issues.
Always refer to the official release compatibility matrix to verify which versions work together.
Check your current versionsβ
Identify which components need updating.
Check runtime package versionsβ
npm list @midnight-ntwrk/compact-runtime
npm list @midnight-ntwrk/ledger
npm list @midnight-ntwrk/zswap
All runtime packages should use the same version number.
Check proof server versionβ
If running the proof server using Docker:
docker ps | grep proof-server
docker logs [proof-server-container-id] | head -20
Look for version information in the startup logs.
Compare versions with the compatibility matrixβ
Review the release compatibility matrix and verify your versions are compatible.
All components show compatible versions according to the official matrix.
Align component versionsβ
Update components to compatible versions using the official compatibility matrix.
Consult the compatibility matrixβ
Review the release compatibility matrix to find compatible versions for:
- Compact compiler
- Runtime packages
- Proof server
- Indexer (if used)
Update runtime packagesβ
Update your package.json with compatible versions from the matrix:
{
"dependencies": {
"@midnight-ntwrk/compact-runtime": "x.x.x",
"@midnight-ntwrk/ledger": "x.x.x",
"@midnight-ntwrk/zswap": "x.x.x",
"@midnight-ntwrk/wallet": "x.x.x"
}
}
Install the updated packages:
npm install
Update proof serverβ
If using Docker, update your container image to a compatible version:
# Stop current container
docker-compose down
# Update docker-compose.yml with compatible version
# Then restart
docker-compose up -d
Update the compilerβ
Download and install the compatible compiler version from the Compact releases.
Verify installation:
compact --version
Recompile contractsβ
After updating components, recompile your smart contracts:
# Clean old artifacts
rm -rf contract/*.cjs contract/*.prover contract/*.verifier
# Recompile using direct compact command
compact compile src/contract.compact contract/
When updating any component, check the compatibility matrix and update all related components together to maintain compatibility.
Lock exact versionsβ
Prevent automatic version updates that could break compatibility.
Use exact version numbersβ
In your package.json, specify exact versions without range operators:
{
"dependencies": {
"@midnight-ntwrk/compact-runtime": "x.x.x",
"@midnight-ntwrk/ledger": "x.x.x"
}
}
Don't use ^x.x.x or ~x.x.x. Always specify exact versions like x.x.x to prevent unexpected updates.
Use npm ci for installationsβ
Use npm ci instead of npm install for reproducible builds:
# Clean install from lock file
rm -rf node_modules
npm ci
This installs exact versions from package-lock.json.
Document your versionsβ
Create a VERSIONS.md file documenting your component versions:
# Component Versions
Last verified: 2025-10-17
## Versions in Use
- Compact compiler: x.x.x
- Runtime packages: x.x.x
- Proof server: x.x.x
- Node.js: xx.x.x
## Compatibility Reference
See: /relnotes/support-matrix
Platform-specific considerationsβ
- Linux
- macOS
- Windows/WSL
Ensure all components are properly installed and accessible:
# Check compiler location
which compact
# Verify Node.js version
node --version
For Apple Silicon (M1/M2), ensure Docker images use the correct architecture:
# Check Docker architecture
docker info | grep Architecture
Use WSL-native paths for consistency:
# Use native WSL paths
cd /home/username/project # Not /mnt/c/...
# Verify compiler access
compact --version
Create a version check scriptβ
Automate version checking with this script:
#!/bin/bash
echo "=== Midnight Version Check ==="
echo ""
echo "Compiler:"
compact --version || echo "β Compiler not found"
echo ""
echo "Runtime packages:"
npm list --depth=0 | grep @midnight-ntwrk || echo "