Skip to content

watch mode should restart a script when it exiting with an error code like nodemon does #57657

@doberkofler

Description

@doberkofler

What is the problem this feature will solve?

This is the default behavior in nodemon and would allow to automatically restart a script (in my case a web server) when an error forces the script to exit.

Example:

When running the sample file fail.js using node --watch=fail.ts fail.js, the following output is generated

Exit with code 1
Failed running 'fail.js'

but the script is actually not restarted as I would have expected from the default behavior in nodemon that I'm trying to replace.

const exitCode = 1;
console.log(`Exit with code ${exitCode}`);
process.exit(exitCode);

What is the feature you are proposing to solve the problem?

Either automatically restart the script when it exists with an error code when --watch is used automatically or add a specific cli option (--watch-restart-on-error) that enables this.

What alternatives have you considered?

Sticking with nodemon

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    Status

    Awaiting Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions