could be fuel pump relay or enercia switch under R/front dashboard push the plunger in on top of switch is the fuel pump running when you turn on the key to run position?
Anytime it dies but still cranks and won't restart, check the black lead from the negative battery terminal. If it's unplugged or not making a connection, it will crank until you run out of juice but will not start.
RepairPal Certified shops can diagnose and repair your 1999 Ford Ranger. They provide transparent pricing with a minimum 12-month or 12,000-mile warranty on repairs and services.