Any way to force strict mode in node?


Question

Could not find this answer anywhere, but I did find several mailing lists where this was discussed, these are rather old however and I have no idea if this is implemented or not.

Is there anyway to force using strict mode in node.js?

Writing "use strict"; in all my .js files... well, i prefer it being forced to using strict mode, rather than adding extra boilerplate.

1
135
9/18/2013 6:50:25 PM

Accepted Answer

According to Lloyd you can now place

"use strict";

at the top of your file in node >= 0.10.7, but if you want your whole app to run in strict (including external modules) you can do this

node --use_strict

197
11/16/2016 7:48:32 AM

In node 0.10.7 you can enforce strict mode at file level by placing "use strict"; at the top of your file. Finally!


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon