Quick solutions to common issues with Mantle Muse.
Error:
ReferenceError: module is not defined in ES module scope
Solution:
The next.config.js file needs to use ES module syntax because package.json has "type": "module".
✅ Fixed! The config now uses export default instead of module.exports.
If you still see this error:
# Verify the fix
cat next.config.js | grep "export default"Error:
DATABASE_URL must be set. Did you forget to provision a database?
Solution:
-
Create
.envfile:cp .env.example .env
-
Edit
.envand set your database URL:DATABASE_URL=postgresql://user:password@localhost:5432/mantlemuse
-
Ensure PostgreSQL is running:
# Check if PostgreSQL is running psql --version pg_isready -
Create database if needed:
createdb mantlemuse
-
Push schema:
npm run db:push
Error:
Please define a NEXTAUTH_SECRET environment variable
Solution:
-
Generate a secure secret:
openssl rand -base64 32
-
Add to
.env:NEXTAUTH_SECRET=your-generated-secret-here NEXTAUTH_URL=http://localhost:3000
-
Restart dev server:
npm run dev
Error:
Port 3000 is already in use
Solution:
# Option 1: Kill the process
npx kill-port 3000
# Option 2: Use different port
PORT=3001 npm run dev
# Option 3 (Windows): Find and kill
netstat -ano | findstr :3000
taskkill /PID <process_id> /FIssue: Redirected to login or home when accessing /admin
Solutions:
-
Not logged in:
- Go to
/auth/login - Login with:
admin@mantlemuse.com/admin123
- Go to
-
Wrong role:
# Check user role in database psql $DATABASE_URL -c "SELECT email, role FROM users WHERE email='admin@mantlemuse.com';" # Update to admin if needed psql $DATABASE_URL -c "UPDATE users SET role='admin' WHERE email='admin@mantlemuse.com';"
-
Session not working:
- Clear browser cookies
- Try incognito/private window
- Check
NEXTAUTH_SECRETis set - Restart dev server
Issue: Logged out after page refresh
Solutions:
-
Check environment variables:
NEXTAUTH_URL=http://localhost:3000 # Must match your domain NEXTAUTH_SECRET=<your-secret> # Must be set
-
Enable cookies in browser:
- Chrome: Settings → Privacy → Cookies → Allow all
- Firefox: Settings → Privacy → Accept cookies
-
Check for HTTPS issues:
- Development: Use
http://localhost:3000 - Production: Use
https://yourdomain.com
- Development: Use
-
Clear cache and restart:
rm -rf .next npm run dev
Issue: Cannot create new users
Solutions:
-
Update database schema:
npm run db:push
-
Check database connection:
psql $DATABASE_URL -c "SELECT 1;"
-
Verify email is unique:
psql $DATABASE_URL -c "SELECT email FROM users WHERE email='test@example.com';"
-
Check server logs for detailed error
Issue: Type errors preventing compilation
Solutions:
-
Check all type errors:
npm run check
-
Clear Next.js cache:
rm -rf .next npm run dev
-
Reinstall dependencies:
rm -rf node_modules package-lock.json npm install
-
Update TypeScript:
npm install -D typescript@latest
Error:
Module not found: Can't resolve '@/components/...'
Solutions:
-
Verify tsconfig.json paths:
{ "paths": { "@/*": ["./src/*"] } } -
Restart dev server:
npm run dev
-
Reinstall dependencies:
npm install
Issue: POST /api/seed returns error
Solutions:
-
Ensure dev server is running:
npm run dev
-
Check database is empty or has few records:
psql $DATABASE_URL -c "SELECT COUNT(*) FROM assets;"
-
Seed via browser:
- Open: http://localhost:3000/api/seed
- Should show success message
-
Check server logs for errors
Issue: npm run build fails
Solutions:
-
Fix TypeScript errors first:
npm run check
-
Fix ESLint warnings:
npm run lint
-
Clear cache and rebuild:
rm -rf .next npm run build
-
Check for missing dependencies:
npm install
Issue: Asset images not displaying
Solutions:
-
Check next.config.js image domains:
images: { remotePatterns: [ { protocol: "https", hostname: "images.unsplash.com" } ] }
-
Verify image URLs are valid
-
Check network tab for 403/404 errors
-
Use HTTPS URLs for images
Issue: API endpoints return 404
Solutions:
-
Verify file structure:
src/app/api/assets/route.ts ✅ src/api/assets/route.ts ❌ Wrong location -
Check route.ts exports:
export async function GET(request: NextRequest) { // Must export GET, POST, etc. }
-
Restart dev server:
npm run dev
Run these to verify your setup:
# 1. Check setup
npm run verify
# 2. Check TypeScript
npm run check
# 3. Check linting
npm run lint
# 4. Test database connection
psql $DATABASE_URL -c "SELECT 1;"
# 5. Check if server is running
curl http://localhost:3000/api/assetsEnable detailed logging:
# Enable debug for NextAuth
DEBUG=next-auth:* npm run dev
# Enable debug for Next.js
NODE_OPTIONS='--inspect' npm run dev-
Check the README:
- Full setup instructions
- Architecture overview
- API documentation
-
Review server logs:
- Look for error messages in terminal
- Check browser console for frontend errors
-
Verify environment:
node --version # Should be 18+ npm --version # Should be 9+ psql --version # Should be 14+
-
Start fresh:
# Nuclear option - clean slate rm -rf node_modules .next npm install npm run db:push npm run dev -
Open an issue:
- Include error messages
- Describe steps to reproduce
- Mention Node.js and OS version
Quick verification that everything is working:
# 1. Environment configured
cat .env | grep DATABASE_URL
cat .env | grep NEXTAUTH_SECRET
# 2. Dependencies installed
ls node_modules | wc -l # Should be 500+
# 3. Database accessible
psql $DATABASE_URL -c "SELECT COUNT(*) FROM assets;"
# 4. Server starts
npm run dev &
sleep 5
curl http://localhost:3000
# 5. API working
curl http://localhost:3000/api/assets
# 6. Login page accessible
curl -I http://localhost:3000/auth/loginIf you accidentally committed secrets:
# 1. Regenerate secrets immediately
openssl rand -base64 32
# 2. Update .env
nano .env
# 3. Ensure .env is in .gitignore
echo ".env" >> .gitignore
# 4. Remove from git history (if committed)
git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch .env" \
--prune-empty --tag-name-filter cat -- --all# 1. Clear cache
rm -rf .next
# 2. Disable experimental features in next.config.js
# Remove: experimental: { ... }
# 3. Reduce hot reload scope
# Edit next.config.js and add:
# watchOptions: { ignored: ['**/node_modules', '**/.git'] }-- Check slow queries
SELECT * FROM pg_stat_statements
ORDER BY mean_exec_time DESC LIMIT 10;
-- Add indexes if needed
CREATE INDEX idx_assets_type ON assets(type);
CREATE INDEX idx_users_email ON users(email);Last Updated: January 2025
Project Version: 2.0