Skip to content

CLI --eval rejects valid trailing line comments when input contains crypto #67159

Open

Description

@CaliLuke

Node.js version and platform

Node.js v26.12.1, macOS arm64. Reproduced with the Node executable directly; no packages or application setup are needed.

Reproduction

Run:

node -e 'crypto; // comment'

The command exits with status 1. It reports this generated source and error:

(crypto=>{{crypto; // comment}})(require('node:crypto'))
SyntaxError: Unexpected end of input

The same failure occurs with --input-type=commonjs. These controls both exit successfully:

node -e 'crypto;'
node -e 'crypto; /* comment */'

Adding a newline after the line comment also succeeds.

Expected behavior

The original command should exit successfully. Its input is valid JavaScript; the trailing line comment should not consume code inserted by the CLI. This affects command generators or scripts that append a line comment to an otherwise valid --eval input containing crypto.

Source evidence

In eval_string.js at v26.12.1, the crypto compatibility branch inserts the input into a wrapper without a newline before the closing syntax. The error above shows that closing syntax on the commented line. This is a standalone CLI reproduction, not a production-incident claim.

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