React Email “email dev” local development server not launching in Remix

I’m having trouble getting React Email’s local development server to work on a remix project. I use Vite and Docker to develop my project. Running my setup script, I see a problem with how React Email imports ora and strip-ansi. Here is my current setup script based on a guide I tried to follow.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { spawn } from "child_process";
import prompt from "prompt";
import dotenv from "dotenv";
import chalk from "chalk";
// add all the env you wish here
const ENVIRONMENTS = ["stage", "prod", "test"];
const getEnvInfo = () => {
// Gets the environment from the command line arguments if set, otherwise defaults to dev
const env = process.argv.find((arg) => ENVIRONMENTS.includes(arg)) ?? "";
// Sets the environment name to be console logged for info
const envName = env !== "" ? env : "dev";
// Allows for reading from .env .env.prod .env.stage etc
const path = `.env${env ? `.${env}` : ""}`;
return { env, envName, path };
};
// Helper method used to confirm the run
const confirmRun = async () => {
const { envName } = getEnvInfo();
console.log(
`About to execute the command in ${chalk.bold.red(envName)} environment.`
);
const { sure } = await prompt.get([
{
name: "sure",
description: "Are you sure? (y/n)",
type: "string",
required: true,
},
]);
if (sure !== "y") {
console.log(chalk.bold.red("Command aborted!n"));
process.exit(1);
}
};
const setupEnv = () => {
const { envName, path } = getEnvInfo();
console.log(chalk.green(`Loading environment: ${envName}`));
dotenv.config({ path });
console.log(
`Environment loaded: ${chalk.green(envName)} from ${chalk.green(path)}`
);
};
const initEmailSystem = async () => {
if (process.platform === 'win32') {
await import('ora').then(oraPackage => {
const ora = oraPackage.default;
const spinner = ora('Initializing email system...').start();
setTimeout(() => {
spinner.succeed('Email system ready');
}, 1000);
});
} else {
console.log('Email system initialization skipped on non-Windows platform');
}
};
if (!process.argv[2]) {
chalk.red("Missing command to run argument");
process.exit(1);
}
// Injects .env variables into the process
setupEnv();
await initEmailSystem();
// Main command to run
const main = () => {
// Allows us to run scripts from the scripts folder without having to wrap them in package.json with npm run execute
const command = process.argv[2].startsWith("scripts/")
? `npm run execute ${process.argv[2]}`
: process.argv[2];
// Filter out the script command and the environment (the slice(3) part) and remove our custom args and pass everything else down
const filteredArgs = process.argv
.slice(3)
.filter((arg) => !ENVIRONMENTS.includes(arg) && arg !== "confirm");
// Spawns a child process with the command to run
// param 1 - command to run
// param 2 - arguments to pass to the command
// param 3 - options for the child process
const child = spawn(command, filteredArgs, {
cwd: process.cwd(),
stdio: "inherit",
shell: true,
});
// If the child process exits, exit the parent process too if the exit code is not 0
child.on("exit", (exitCode) => {
if (exitCode !== 0) {
process.exit(exitCode ?? 1);
}
});
//
["SIGINT", "SIGTERM"].forEach((signal) => {
process.on(signal, () => {
// Kills the child only if it is still connected and alive
if (child.connected) {
child.kill(child.pid);
}
process.exit(1);
});
});
};
// Makes the user confirm the run if the confirm argument is passed
if (process.argv.includes("confirm")) {
confirmRun()
.then(() => {
main();
})
.catch(() => process.exit(1));
// If the confirm argument is not passed, just run the command
} else {
main();
}
</code>
<code>import { spawn } from "child_process"; import prompt from "prompt"; import dotenv from "dotenv"; import chalk from "chalk"; // add all the env you wish here const ENVIRONMENTS = ["stage", "prod", "test"]; const getEnvInfo = () => { // Gets the environment from the command line arguments if set, otherwise defaults to dev const env = process.argv.find((arg) => ENVIRONMENTS.includes(arg)) ?? ""; // Sets the environment name to be console logged for info const envName = env !== "" ? env : "dev"; // Allows for reading from .env .env.prod .env.stage etc const path = `.env${env ? `.${env}` : ""}`; return { env, envName, path }; }; // Helper method used to confirm the run const confirmRun = async () => { const { envName } = getEnvInfo(); console.log( `About to execute the command in ${chalk.bold.red(envName)} environment.` ); const { sure } = await prompt.get([ { name: "sure", description: "Are you sure? (y/n)", type: "string", required: true, }, ]); if (sure !== "y") { console.log(chalk.bold.red("Command aborted!n")); process.exit(1); } }; const setupEnv = () => { const { envName, path } = getEnvInfo(); console.log(chalk.green(`Loading environment: ${envName}`)); dotenv.config({ path }); console.log( `Environment loaded: ${chalk.green(envName)} from ${chalk.green(path)}` ); }; const initEmailSystem = async () => { if (process.platform === 'win32') { await import('ora').then(oraPackage => { const ora = oraPackage.default; const spinner = ora('Initializing email system...').start(); setTimeout(() => { spinner.succeed('Email system ready'); }, 1000); }); } else { console.log('Email system initialization skipped on non-Windows platform'); } }; if (!process.argv[2]) { chalk.red("Missing command to run argument"); process.exit(1); } // Injects .env variables into the process setupEnv(); await initEmailSystem(); // Main command to run const main = () => { // Allows us to run scripts from the scripts folder without having to wrap them in package.json with npm run execute const command = process.argv[2].startsWith("scripts/") ? `npm run execute ${process.argv[2]}` : process.argv[2]; // Filter out the script command and the environment (the slice(3) part) and remove our custom args and pass everything else down const filteredArgs = process.argv .slice(3) .filter((arg) => !ENVIRONMENTS.includes(arg) && arg !== "confirm"); // Spawns a child process with the command to run // param 1 - command to run // param 2 - arguments to pass to the command // param 3 - options for the child process const child = spawn(command, filteredArgs, { cwd: process.cwd(), stdio: "inherit", shell: true, }); // If the child process exits, exit the parent process too if the exit code is not 0 child.on("exit", (exitCode) => { if (exitCode !== 0) { process.exit(exitCode ?? 1); } }); // ["SIGINT", "SIGTERM"].forEach((signal) => { process.on(signal, () => { // Kills the child only if it is still connected and alive if (child.connected) { child.kill(child.pid); } process.exit(1); }); }); }; // Makes the user confirm the run if the confirm argument is passed if (process.argv.includes("confirm")) { confirmRun() .then(() => { main(); }) .catch(() => process.exit(1)); // If the confirm argument is not passed, just run the command } else { main(); } </code>
import { spawn } from "child_process";
import prompt from "prompt";
import dotenv from "dotenv";
import chalk from "chalk";
// add all the env you wish here
const ENVIRONMENTS = ["stage", "prod", "test"];

const getEnvInfo = () => {
  // Gets the environment from the command line arguments if set, otherwise defaults to dev
  const env = process.argv.find((arg) => ENVIRONMENTS.includes(arg)) ?? "";
  // Sets the environment name to be console logged for info
  const envName = env !== "" ? env : "dev";
  // Allows for reading from .env .env.prod .env.stage etc
  const path = `.env${env ? `.${env}` : ""}`;
  return { env, envName, path };
};

// Helper method used to confirm the run
const confirmRun = async () => {
  const { envName } = getEnvInfo();
  console.log(
    `About to execute the command in ${chalk.bold.red(envName)} environment.`
  );

  const { sure } = await prompt.get([
    {
      name: "sure",
      description: "Are you sure? (y/n)",
      type: "string",
      required: true,
    },
  ]);

  if (sure !== "y") {
    console.log(chalk.bold.red("Command aborted!n"));
    process.exit(1);
  }
};

const setupEnv = () => {
  const { envName, path } = getEnvInfo();
  console.log(chalk.green(`Loading environment: ${envName}`));
  dotenv.config({ path });
  console.log(
    `Environment loaded: ${chalk.green(envName)} from ${chalk.green(path)}`
  );
};

const initEmailSystem = async () => {
  if (process.platform === 'win32') {
    await import('ora').then(oraPackage => {
      const ora = oraPackage.default;
      const spinner = ora('Initializing email system...').start();
      setTimeout(() => {
        spinner.succeed('Email system ready');
      }, 1000);
    });
  } else {
    console.log('Email system initialization skipped on non-Windows platform');
  }
};

if (!process.argv[2]) {
  chalk.red("Missing command to run argument");
  process.exit(1);
}
// Injects .env variables into the process
setupEnv();
await initEmailSystem();

// Main command to run
const main = () => {
  // Allows us to run scripts from the scripts folder without having to wrap them in package.json with npm run execute
  const command = process.argv[2].startsWith("scripts/")
    ? `npm run execute ${process.argv[2]}`
    : process.argv[2];
  // Filter out the script command and the environment (the slice(3) part) and remove our custom args and pass everything else down
  const filteredArgs = process.argv
    .slice(3)
    .filter((arg) => !ENVIRONMENTS.includes(arg) && arg !== "confirm");
  // Spawns a child process with the command to run
  // param 1 - command to run
  // param 2 - arguments to pass to the command
  // param 3 - options for the child process
  const child = spawn(command, filteredArgs, {
    cwd: process.cwd(),
    stdio: "inherit",
    shell: true,
  });
  // If the child process exits, exit the parent process too if the exit code is not 0
  child.on("exit", (exitCode) => {
    if (exitCode !== 0) {
      process.exit(exitCode ?? 1);
    }
  });
  //
  ["SIGINT", "SIGTERM"].forEach((signal) => {
    process.on(signal, () => {
      // Kills the child only if it is still connected and alive
      if (child.connected) {
        child.kill(child.pid);
      }
      process.exit(1);
    });
  });
};
// Makes the user confirm the run if the confirm argument is passed
if (process.argv.includes("confirm")) {
  confirmRun()
    .then(() => {
      main();
    })
    .catch(() => process.exit(1));

  // If the confirm argument is not passed, just run the command
} else {
  main();
}

My script command is “email dev” like this. Other development scripts work but not React Email.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>"email": "npm run script "email dev --dir ~/emails"",
</code>
<code>"email": "npm run script "email dev --dir ~/emails"", </code>
"email": "npm run script "email dev --dir ~/emails"",

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật