Man I have sunk a couple of hours into this problem and I still have no idea where to even begin :D It's really not an easy problem depending on how complex you want it. I'd argue the build-in pathfinding behavior is not suited for this type of problem. I've personally never managed to solve it.
The basic idea is building a nodetree with connections, then use A* to find a path through that tree. But as to how to have the enemy properly traverse along the path... no clue.
Maybe now that I have a bit more clue about js I could try again but this is rough.
For a much more basic implementation. A handful of raycasts can do the trick.
-Move towards the target sprite (either left or right)
-Shoot one ahead of the enemy, if it hits a wall -> jump
-Shoot one down from the enemies feet, if it doesn't hit anything there's a pit -> jump.
This is crude and will not work for anything that requires more complex pathing.