Kind of the point.
The problem was not quite as universal as you think, at least in perspective or fleet thinking.
The US had lots of bristling flak ships in 1939 and many more on the way.

It turns out that what they thought would work didn't, at least until 1943.
The US Farragut class.
View attachment 705996
Of 1934-45 was just about as naked as any other Destroyer of the 1930s ( exceptions later) when it came to
light AA. Four water cooled .50 cal guns were hardly sufficient even in 1935. However the big difference between the US Destroyers of the time (forget the 4 stackers) was that their 5in guns were dual purpose and true dual purpose, not dual purpose in name only. The Guns would elevate to 85 degrees, there were fuse setters on the mounts, there was a dual purpose gun director on top of the bridge. These mounts were not as good as the later mounts but compared to the British 4.7in guns of the time?????
At least the US destroyers could fire
something into the air more the .50 cal guns.
The Germans never put DP guns on their destroyers.
If the French did it was only the very last ships built if any of them were completed as designed.
Italian destroyers never got true dual purpose guns, they could elevate to 40-45 degrees but they fired slowly (about 1/2 as fast as the Farraguts and they were slow compared to late US destroyers).
The Japanese were the only other navy to actual fit DP guns to their destroyers. That is guns that could elevate over 45 degrees. We can argue over rates of fire and rates of train and elevation but if your main destroyer guns won't elevate past 45 degrees and you have no real provision for AA fire control (high angle director, not low angle director making guesses)
then you are pretty much depending on maneuver and an handful (and a small hand full at that) of 12.7-13.2mm machine guns.
I would also note that the US had a tiny sliver of an advantage with the AA machine guns in that the .50 was water cooled and belt fed. The French, Italian and Japanese 13.2mm machine guns were air cooled and fed from 30 round magazines.
The US was also waiting for the 1.1 in gun to make it's long awaited appearance
The Germans may have had the best light AA. They had their 37mm
semi-automatic guns and they had the old 20mm AA guns that fired under 300rpm.
British pulled a set of torpedo tubes off their ships and mounted an old 3in or 4in gun without any director to at least fire something upward. A few major shell bursts helped the crew think they were at least fighting back.
The US had deliberately sacrificed anti-ship capability with the 5in/38 for AA capability. Of course the long range anti-ship capability that other Navies were obsessed with was largely an illusion. Destroyers (especially before radar) didn't have the ability to spot the fall of shot, good enough range finders or steady enough platforms (less rock and pitch) to effectively fire at long range.
The French and German big destroyers with their 5.5 and 5.9 in guns were really backed into a corner when it came to AA.
So yes, there was a slow trickle of light AA guns sprinkled lightly over the ships of many fleets for several years. But the AA situation of even early/mid 1942 was not the situation of 1940.