Unfortunately not. That’s why I asked. 
No enemies got spawned in my case. That’s probably the reason why I didn’t get the NullReferenceException and the KeyNotFoundException.
Updated Sun Apr 25 2021 16:08
I have investigated the problem a bit further. The pool size of the ObjectPool component of the ObjectPool game object was 0, so I set it to 1.

Now I’m getting two error messages:
Then I checked the script execution order. There is no ObjectPool or GridManager object in the list.

I added GridManager and ObjectPool to the list.

A Debug.Log in the EnemyMover revealed that the List object existed, but the List object did not contain any elements.
private void ReturnToStart()
{
Debug.Log("path: " + path);
Debug.Log("path.Count: " + path.Count);
transform.position = path[0].transform.position;
}
I checked where elements get added to the list.
foreach (Transform child in parent.transform)
{
Waypoint waypoint = child.GetComponent<Waypoint >();
if (waypoint != null)
{
path.Add(waypoint);
}
}
According to this piece of code, the child gets added only if a Waypoint component is attached to it. There is no Waypoint component attached to any of the children of the Path game object.

After I had added the Waypoint component, the enemy started to move, and no errors got thrown anymore.