Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Not loading app.ts #338

@ghostlexly

Description

@ghostlexly

Issue description

The app is not loaded when i require it in my main entry script.

I have 2 files:

  • server.ts - for running workers in cluster mode
  • app.ts - the file that serve the application data

Context

OS version (is it docker or host?), ts-node-dev version: Docker

Did you try to run with ts-node? : yes, it's working with ts-node

Did you try to run with --files option enabled? Yes

Did you try to run with --debug option enabled? Yes

Do you have a repro example (git repo) with simple steps to reproduce your problem?

const cluster = require("cluster");
const numCPUs = require("os").cpus().length;

/** Initiate a Cluster */
if (cluster.isMaster) {
  console.log(`Master ${process.pid} is running`);

  // Fork worker processes
  for (let i = 0; i < numCPUs; i++) {
    cluster.fork();
  }

  cluster.on("online", (worker) => {
    console.log(`Worker ${worker.process.pid} is running`);
  });

  // Handle worker process exit and create a new one
  cluster.on("exit", (worker, code, signal) => {
    console.log(`Worker ${worker.process.pid} died`);
    cluster.fork();
  });
} else {
  require("./app"); // this is not loaded
}

My cli command:

ts-node-dev --respawn --transpile-only -r tsconfig-paths/register src/server.ts

Debug log:

gistique-backend-1  | [INFO] 10:33:58 Restarting: /usr/src/app/src/server.ts has been modified
logistique-backend-1  | [DEBUG] 10:33:58 /usr/src/app/src/server.ts compiled in 12 ms
logistique-backend-1  | [DEBUG] 10:33:58 Removing all watchers from files
logistique-backend-1  | [DEBUG] 10:33:58 Child is already stopped, probably due to a previous error
logistique-backend-1  | [DEBUG] 10:33:58 Starting child process -r /tmp/ts-node-dev-hook-7154198465957726.js -r tsconfig-paths/register /usr/src/app/node_modules/ts-node-dev/lib/wrap.js src/server.ts
logistique-backend-1  | [DEBUG] 10:33:58 /usr/src/app/src/server.ts added to watcher
logistique-backend-1  | [DEBUG] 10:31:51 /usr/src/app/src/server.ts added to watcher
logistique-backend-1  | [DEBUG] 10:31:51 /usr/src/app/src/app.ts added to watcher

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions