The key is finding a position opposite of where the player is.
Get the angle between player and enemy with angle(player.X, player.Y, enemy.X, enemy.Y)
Convert it to vectors using cos() and sin()
Define a distance the enemies should run away
Then make them run :)
For pathfinding you'd also have to find the path to that position. In this case the endposition could for example end up inside a wall, which will trigger "on failed to find path". So you'll need some extra handling in place to make sure the endposition is not inside a solid object.