SyntaxError: Strict mode code may not include a with statement

#1

Hi

With the latest update of my package I added "use strict"; to my RunKit example (https://npm.runkit.com/hyphenopoly). Now I get the following errors:

SyntaxError: Strict mode code may not include a with statement

A stack trace for this error could not be retrieved because stack was already called.

When I remove "use strict"; everything works as expected.
I’m very sure that I haven’t used a with statement in my code.

Does RunKit eventually use with somewhere?

Thanks,
Mathias

0 Likes

#2

with was deprecated a very long time ago, which is probably why you cannot use it when strict mode is enabled.

You can see that as of ecmascript 5.1 it’s been disallowed in strict mode: https://www.ecma-international.org/ecma-262/5.1/#sec-12.10

0 Likes

#3

That’s why I don’t use with at all (as I noted).
BTW: I see the same error on all RunKit notebooks when I write "use strict"; on top…

When I run the code on node v0.12.18 I get the following error:

SyntaxError: /app/index.js:4
  with (arguments[0]) {
  ^^^^
Strict mode code may not include a with statement
0 Likes