Wednesday, 26 April 2017

Check if is console execution with babel

How can I check if node is invoked via console, and not with require, if I use babel to transpile from es6 to es5?

Normally, without babel, I would use:

if (require.main === module)

But it doesn't work with babel. It's false in both cases. Why is that so? How can I do it then?



via user99999

No comments:

Post a Comment