Skip to content

Commit

Permalink
fix: Next.js server startup process
Browse files Browse the repository at this point in the history
  • Loading branch information
atrincas committed Jan 7, 2025
1 parent 9fa0347 commit d353dff
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
const { spawn } = require('child_process');
const path = require('path');

const nextPath = path.join(__dirname, 'node_modules', '.bin', 'next');

process.argv.length = 1;
process.argv.push(nextPath, 'start');
const nextProcess = spawn(nextPath, ['start'], {
stdio: 'inherit',
});

nextProcess.on('error', (err) => {
console.error('Failed to start Next.js:', err);
process.exit(1);
});

// eslint-disable-next-line import/no-dynamic-require
require(nextPath);
nextProcess.on('exit', (code) => {
process.exit(code);
});

0 comments on commit d353dff

Please sign in to comment.