Skip to content

node --watch bails on invalid import syntax #62022

Description

@valler

Version

25

Platform

Darwin

Subsystem

No response

What steps will reproduce the bug?

  1. The module
// index.mjs
import
  1. Run
node --watch .

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

What: Don't exit.
Why: Because it should watch.

What do you see instead?

Node bails out with exit code 0.

% node --watch .
file:/// ... /index.mjs:2



SyntaxError: Unexpected end of input
    at compileSourceTextModule (node:internal/modules/esm/utils:357:16)
    at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:109:18)
    at #translate (node:internal/modules/esm/loader:564:20)
    at afterLoad (node:internal/modules/esm/loader:614:29)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:619:12)
    at #createModuleJob (node:internal/modules/esm/loader:643:36)
    at #getJobFromResolveResult (node:internal/modules/esm/loader:353:34)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:318:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:685:25)

Node.js v25.0.0
Failed running '.'. Waiting for file changes before restarting...

Additional information

Similar to #62021

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions