Fix package repository access failures
Resolve 403 Forbidden errors encountered when installing Midnight packages.
Understanding the errorβ
When installing Midnight packages, the following errors may appear:
npm install @midnight-ntwrk/compact-runtime
npm ERR! code E403
npm ERR! 403 Forbidden - GET https://registry.npmjs.org/@midnight-ntwrk/compact-runtime
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy
Solution 1: Reset npm registryβ
The most common cause is an npm configuration pointing to the wrong registry.
Check current registryβ
npm config get registry
If the output differs from https://registry.npmjs.org/, the registry configuration is incorrect.
Reset to default registryβ
npm config set registry https://registry.npmjs.org/
npm config delete @midnight-ntwrk:registry
npm cache clean --force
Test installationβ
npm install @midnight-ntwrk/compact-runtime
Verification: Package installs successfully without errors.
Solution 2: Fix VPN and proxy issuesβ
Corporate VPNs or proxies can block npm access.
Disable VPN temporarilyβ
On corporate networks, disabling a VPN connection may not be permitted.
Disconnect from the VPN and test:
npm install @midnight-ntwrk/compact-runtime
If the installation succeeds, VPN restrictions are blocking npm access. Configure proxy settings instead.
Configure proxy (if VPN is required)β
# Set proxy settings
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
# With authentication
npm config set proxy http://username:password@proxy.company.com:8080
npm config set https-proxy http://username:password@proxy.company.com:8080
Test installationβ
npm install @midnight-ntwrk/compact-runtime
Verification: Package installs successfully through proxy.
Solution 3: Clear configuration and start freshβ
Conflicting npm configurations can cause 403 errors. Reset npm to restore defaults.
Back up and clear configurationβ
Back up the npm configuration before clearing it, as this process removes all custom settings.
# Back up existing config
cp ~/.npmrc ~/.npmrc.backup
# Remove all settings
npm config delete registry
npm config delete proxy
npm config delete https-proxy
npm config delete @midnight-ntwrk:registry
Set defaults and clean projectβ
The following commands delete node_modules and package-lock.json. Ensure the correct project directory is active before proceeding.
# Set registry
npm config set registry https://registry.npmjs.org/
# Clean project
rm -rf node_modules package-lock.json
npm cache clean --force
Test installationβ
npm install @midnight-ntwrk/compact-runtime
Verification: Package installs successfully.
Platform-specific fixesβ
- Windows/WSL
- Linux
- macOS
# Configure git line endings
git config --global core.autocrlf false
# Use native WSL paths (not /mnt/c/...)
cd /home/yourusername/project
# Clear Windows npm cache
rm -rf /mnt/c/Users/YourName/AppData/Roaming/npm-cache
# Configure npm without sudo
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
# Add to ~/.bashrc
export PATH=~/.npm-global/bin:$PATH
source ~/.bashrc
The system may prompt for a password when running this command.
# Clear keychain credentials
security delete-generic-password -s 'npm' -a 'bearer'
Quick fix scriptβ
Create an automated fix script:
#!/bin/bash
echo "π§ Fixing Midnight npm installation..."
# Clear configuration
npm config delete registry
npm config delete @midnight-ntwrk:registry
npm config delete proxy
npm config delete https-proxy
# Set defaults
npm config set registry https://registry.npmjs.org/
npm cache clean --force
# Clean project (only if package.json exists)
if [ -f "package.json" ]; then
echo "π Cleaning project files..."
rm -rf node_modules package-lock.json
else
echo "β οΈ No package.json found - skipping project cleanup"
fi
# Test installation
echo "π§ͺ Testing package installation..."
npm install @midnight-ntwrk/compact-runtime
if [ $? -eq 0 ]; then
echo "β
Success! Midnight packages are accessible."
else
echo "β Installation failed. Try disconnecting from VPN or checking firewall settings."
fi
Run the script:
chmod +x fix-midnight-npm.sh
./fix-midnight-npm.sh
Verify the fixβ
Confirm that all configurations and installations are functioning correctly:
# Check registry
npm config get registry
# Expected output: https://registry.npmjs.org/
# Test package access
npm view @midnight-ntwrk/compact-runtime
# Expected output: package information
# Verify installation
npm install @midnight-ntwrk/compact-runtime
# Expected result: successful installation
Still not working?β
Enable verbose logging
Display detailed error information:
npm install @midnight-ntwrk/compact-runtime --verbose
Common issues include:
- SSL certificate issues
- Proxy configuration problems
- DNS resolution failures
Test direct connection
Verify registry access:
curl https://registry.npmjs.org/@midnight-ntwrk/compact-runtime
A failed request indicates a network connectivity issue.
Next stepsβ
After installation completes successfully, verify the development environment:
# Check installed packages
npm list @midnight-ntwrk
# Verify compiler
compact --version
# Test runtime import
node -e "const runtime = require('@midnight-ntwrk/compact-runtime'); console.log('β
Runtime loaded');"
Install Development Toolsβ
-
Installation guide - Comprehensive setup guide covering the Lace wallet, test tokens, Compact compiler, and proof server installation
-
Build a DApp tutorial - Detailed instructions for installing Node.js, the Compact developer tools, and verifying your installation
-
Install the Compact developer tools - Specific section on installing and managing the Compact compiler toolchain
Configure Your Environmentβ
-
Development Environment for Writing and Deploying Midnight Applications - Step-by-step environment setup including Docker, Chrome browser, Lace wallet, and proof server configuration
-
Environment Setup and First Contract - Foundational steps for configuring your development environment with all necessary tools
-
Prerequisites - Platform requirements and Docker setup instructions
These guides cover everything from basic prerequisites (Docker, Node.js) to installing the Compact compiler and setting up the proof server for local development.