Code Whisperer Code Whisperer - 6 months ago 25
Node.js Question

How to Skip Using "use strict" In Node.js 4.0+?

Using

"use strict"
allows support for ES6 features, which Node 4.0 supports, in JavaScript code.

However, it is cumbersome to have this at the beginning of every single back-end code file.

Is there a way to configure Node to just assume
"use strict"
is always in use within an application?

Answer

You can pass the --use_strict command line option to the node command. This will treat all of your code as being in strict mode.

Alternately, you can use the package https://www.npmjs.com/package/use-strict. That way you don't have to give the command line argument each time.