call flock with node.js?

Problem

I have cron job to run node.js scripts.

Want to use flock to lock a file to make sure my cron jobs are not overlapped.

Any good module for doing file locking ?

Or I should call that in child process ?

Or I should not do any file locking ?

Sorry, I am new to this and not sure file locking is good for async env like node. Thanks

Problem courtesy of: Eric Fong

Solution

See flock function in fs-ext package: https://github.com/baudehlo/node-fs-ext

Solution courtesy of: alex

View additional discussion.