mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-11 17:29:48 +02:00
Ensure the application runs correctly in the production environment
Implements a Node.js 18 compatibility fix by patching `dist/index.js` and creating `server/prod-start.js` to replace `import.meta.dirname` with static paths, resolving a runtime error. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 91318273-c764-4fd4-be04-bdc12c38af32 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/99451107-d8a0-4f61-81e0-cae481285260.jpg
This commit is contained in:
1 parent
4c9263b51a
commit
07baa59225
6 files changed
+53
-10
No files matched your search
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Polyfill pour import.meta.dirname dans Node.js 18
|
||||
import { fileURLToPath } from 'url';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
// Obtenir le répertoire courant
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const projectRoot = path.resolve(__dirname, '..');
|
||||
|
||||
// Lire le fichier dist/index.js et remplacer import.meta.dirname
|
||||
const distPath = path.join(projectRoot, 'dist', 'index.js');
|
||||
let distContent = fs.readFileSync(distPath, 'utf-8');
|
||||
|
||||
// Remplacer toutes les instances de import.meta.dirname par une valeur statique
|
||||
const replacement = `"${projectRoot.replace(/\\/g, '\\\\')}"`;
|
||||
distContent = distContent.replace(/import\.meta\.dirname/g, replacement);
|
||||
|
||||
// Aussi corriger les chemins pour le serveur statique
|
||||
distContent = distContent.replace(/path3\.resolve\(\s*import\.meta\.dirname,\s*"public"\s*\)/g,
|
||||
`path3.resolve("${projectRoot.replace(/\\/g, '\\\\')}", "public")`);
|
||||
|
||||
// Écrire le fichier modifié
|
||||
fs.writeFileSync(distPath, distContent);
|
||||
|
||||
console.log('✅ Node.js 18 compatibility fix applied');
|
||||
|
||||
// Démarrer l'application
|
||||
import('../dist/index.js').catch(console.error);
|
||||
Reference in new issue
Block a user