Kraft102 commited on
Commit
f59c492
·
verified ·
1 Parent(s): 60ba737

Fix import.meta.url CJS compatibility

Browse files
apps/backend/src/services/harvester/PythonHarvesterAdapter.ts CHANGED
@@ -3,8 +3,11 @@ import path from 'path';
3
  import { EventEmitter } from 'events';
4
  import { fileURLToPath } from 'url';
5
 
6
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
- const PYTHON_DIR = path.resolve(__dirname, '../../../python');
 
 
 
8
 
9
  export interface HarvestResult {
10
  success: boolean;
 
3
  import { EventEmitter } from 'events';
4
  import { fileURLToPath } from 'url';
5
 
6
+ // Handle both ESM and CJS contexts (import.meta.url is undefined in bundled CJS)
7
+ const __dirname = typeof import.meta?.url !== 'undefined'
8
+ ? path.dirname(fileURLToPath(import.meta.url))
9
+ : process.cwd();
10
+ const PYTHON_DIR = path.resolve(__dirname, 'python');
11
 
12
  export interface HarvestResult {
13
  success: boolean;