Several translations render "no" as "neither," and this makes good sense in context. But the real issue was not whether God was for Joshua's side or his enemies' side, but whether Joshua stood before God in submission. So the angel immediately commanded Joshua to humble himself. The scene is a parallel to the appearance of the the angel of the Lord to Moses in Exodus 3:
The angel of the Lord appeared to him as fire flaming out of a
bush...4 When the Lord saw that he had turned aside to look, God
called out to him from the bush: Moses! Moses! He answered, “Here I
am.” 5 God said: Do not come near! Remove your sandals from your feet,
for the place where you stand is holy ground
In Joshua's case, it is not the Lord who speaks first. Instead, Joshua takes the initiative and demands to know the "man's" allegiance. "Are you for us, or for our adversaries?"
14 He replied, “Neither. I am the commander of the army of the Lord:
now I have come.” Then Joshua fell down to the ground in worship, and
said to him, “What has my lord to say to his servant?” 15 The
commander of the army of the Lord replied to Joshua, “Remove your
sandals from your feet, for the place on which you are standing is
holy.” And Joshua did so. (NABRE)
Conclusion: Joshua failed to recognize the person who appeared and as a result did not adopt the proper attitude at first. He saw a military commander and demanded to know which side the "man" supported. In fact, he saw the angel of the Lord. The proper attitude for Joshua was submission to God, not to demand a statement of allegiance to one side or the other. So the angel answered "no" or "neither." Once Joshua humbled himself and took off his sandals, God did fight for Israel.