Any way to force strict mode in node?

后端 未结 5 1819
故里飘歌
故里飘歌 2020-11-28 21:16

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

5条回答
  •  北海茫月
    2020-11-28 21:39

    You can also use

    https://npmjs.org/package/use-strict

    that is, write once

    require('use-strict')
    

    or even take a step forward and use

    https://npmjs.org/package/node-strict

    Please note that use-strict will turn on strict more on every module required after invocation.

    If you prefer a not invasive approach, I wrote another module

    https://www.npmjs.org/package/strict-mode

    which enables strict mode only in your package. I think that is more a "Do What I Mean" solution.

提交回复
热议问题