nodejs / nodejs/node

--use-strict flag doesn't apply strict mode to script

Open
#30,039 8 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

confirmed-bug v8 engine
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

  • Node 12.*:
  • Windows 64bit, Debian 64bit:

The --use-strict flag doesn't apply strict mode to script.
reproduction:

echo a = 1 > test.js && node --use-strict test

expected behavior:
ReferenceError: a is not defined is thrown.
behavior:
script executes without any issue.

however it works as expected when node is started first and script is called from repl.
<12 versions aren't affected.

node --use-strict
Welcome to Node.js v12.12.0.
Type ".help" for more information.
> a = 1
Thrown:
ReferenceError: a is not defined
>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported command, node --use-strict test, and compare its behavior with the documented REPL example. Trace how --use-strict is applied during script startup; the issue is done when the script throws the expected ReferenceError while the existing REPL behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.