Skip to content

Getting started #5139

Closed
Closed

Description

@John-L

Node.js Version

v24.14.0

NPM Version

v11.9.0

Operating System

Win11 25H2

Subsystem

constants

Description

I'm new to Node.js. All my previous experience with JavaScript is when it is browser-hosted.

Is there a node program control that disables the variable declaration requirement, so that variables can be implicitly declared when an assignment occurs (similar to browser-hosted implementations)?

Minimal Reproduction

file="one";

vs.

const file="one"; or var file="one";

Output

file="one";
^

ReferenceError: file is not defined
at file:///C:/Users/Public/npm/Sample-Const.js:1:5
at ModuleJob.run (node:internal/modules/esm/module_job:430:25)
at async onImport.tracePromise.proto (node:internal/modules/esm/loader:661:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)

Node.js v24.14.0

Before You Submit

  • I have looked for issues that already exist before submitting this
  • My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask

Activity

  1. avivkeller commented on Mar 6, 2026

    @avivkeller
    Member

    Is there a node program control that disables the variable declaration requirement, so that variables can be implicitly declared when an assignment occurs (similar to browser-hosted implementations)?

    Yes. Node.js, and all JavaScript for that matter, either runs in strict or non-strict mode. When running in strict mode, variables must be explicitly declared with their keywords. In non-strict mode, this is not a requirement.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode#invoking_strict_mode

  2. added
    answered🎉 Yay! The issue has been resolved, or the question has been answered.
    on Mar 6, 2026
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

    answered🎉 Yay! The issue has been resolved, or the question has been answered.question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions