0

I am starting to code JavaScript on JetBrains WebStorm, and I am trying to follow a few examples from a book. I am trying to avoid adding use-strict at the start of every code file, knowing fully that using this approach should be used with caution.

When I use a console with node --use-strict (with the flag) and execute the following line:

coutner = 1

I get the expected error: Uncaught ReferenceError: coutner is not defined.

Then I try using the Run/Debug configuration: First, I define a new Run/Debug configuration that uses the same node as before, with a node parameter --use-strict:

enter image description here

Then I execute a file composed of the above code (with or without adding another line: console.log(coutner) after it) using that run configuration, the code executes, and I am not getting the expected error. Why is that?

I've also added the "Non-strict mode used" inspection under Settings -> Editor -> Inspections, and I get no warning for the file mentioned above.

In addition, I am using WebStorm on a Windows 11 computer and Ubuntu-22.04 through WSL2. These examples don't work on both Windows and Ubuntu node.js interpreters.

Any help would be much appreciated.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • could you clarify what you mean by 'running in console'? What console is meant? I can't find `--use-strict` in the list of Node.js options in https://nodejs.org/api/cli.html – lena Apr 07 '23 at 15:45
  • 1
    Ok, seems to be a V8 flag. But it only works in Node REPL, see https://github.com/nodejs/node/issues/30039 – lena Apr 07 '23 at 15:53

0 Answers0