nearestPointOnLine exhibits strange behavior when the line is near-vertical.
For example in this jsfiddle the line goes from [-40,50] to [-40,60], the point is [-40.01,56] and turf returns the nearest point as [-40,~55.3]: https://jsfiddle.net/hdumty60/
I tried playing with the code a bit and the issue went away if I changed nearest-point-on-line to use rhumb destination, not sure if that is an ideal solution though.