From 1c26ed67235b7106e7b94f661314b157338286ef Mon Sep 17 00:00:00 2001 From: William Valentin Date: Sat, 6 Dec 2025 14:05:46 -0800 Subject: [PATCH] fix: update setup-couchdb.js path resolution for container environment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix backendPath to work when script is in backend/scripts/ - Make .env loading conditional (exists check) - Update both backend/scripts/ and scripts/ versions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- backend/scripts/setup-couchdb.js | 9 +++++++-- scripts/setup-couchdb.js | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/scripts/setup-couchdb.js b/backend/scripts/setup-couchdb.js index f0876c2..1d77ea4 100644 --- a/backend/scripts/setup-couchdb.js +++ b/backend/scripts/setup-couchdb.js @@ -2,12 +2,17 @@ // Setup module path to include backend node_modules const path = require('path'); -const backendPath = path.join(__dirname, '..', 'backend'); +const backendPath = path.join(__dirname, '..'); process.env.NODE_PATH = path.join(backendPath, 'node_modules') + ':' + (process.env.NODE_PATH || ''); require('module').Module._initPaths(); const Nano = require('nano'); -require('dotenv').config({ path: path.join(backendPath, '.env') }); +// Load .env file if it exists (for local development) +const dotenvPath = path.join(backendPath, '.env'); +const fs = require('fs'); +if (fs.existsSync(dotenvPath)) { + require('dotenv').config({ path: dotenvPath }); +} // Configuration const COUCHDB_URL = process.env.COUCHDB_URL || 'http://localhost:5984'; diff --git a/scripts/setup-couchdb.js b/scripts/setup-couchdb.js index f0876c2..1d77ea4 100644 --- a/scripts/setup-couchdb.js +++ b/scripts/setup-couchdb.js @@ -2,12 +2,17 @@ // Setup module path to include backend node_modules const path = require('path'); -const backendPath = path.join(__dirname, '..', 'backend'); +const backendPath = path.join(__dirname, '..'); process.env.NODE_PATH = path.join(backendPath, 'node_modules') + ':' + (process.env.NODE_PATH || ''); require('module').Module._initPaths(); const Nano = require('nano'); -require('dotenv').config({ path: path.join(backendPath, '.env') }); +// Load .env file if it exists (for local development) +const dotenvPath = path.join(backendPath, '.env'); +const fs = require('fs'); +if (fs.existsSync(dotenvPath)) { + require('dotenv').config({ path: dotenvPath }); +} // Configuration const COUCHDB_URL = process.env.COUCHDB_URL || 'http://localhost:5984';