Let's say a barbarian named Boomtar is in a room with stalkers and can’t see them because they are invisible and stealthy. Boomtar bravely lunges forward and happens to run into the stalker. May Boomtar then make an attack at the stalker?
Knowing where an invisible creature is allows you to attack them at disadvantage.
There are two related questions, here and here explaining that if you are invisible that other creatures do still know where you are because they can still hear you. The "Unseen Attacks" section states:
When you attack a target that you can't see, you have disadvantage on the attack roll. This is true whether you're guessing the target's location or you're targeting a creature you can hear but not see...
Thus if the target is merely invisible, but can still be heard then you would already know its location and could attack it at disadvantage as described above.
Note that even if a creature were hidden (invisible and inaudible) you could still guess at its location, however the section quoted above continues, saying:
If the target isn't in the location you targeted, you automatically miss, but the DM typically just says that the attack missed, not whether you guessed the target's location correctly...
If a creature instead is hidden, and you bump into it, presumably you would know where it is and thus you could make an attack at disadvantage like in the invisible case. However, there is at least one odd problem which results from the rule on "Moving Around Other Creatures":
You can move through a nonhostile creature's space. In contrast, you can move through a hostile creature's space only if the creature is at least two sizes larger or smaller than you. Remember that another creature's space is difficult terrain for you.
If an enemy were one size larger or smaller than you, then you would be prevented from moving into its space and could simply attack that space at disadvantage.
However if an enemy were at least two sizes larger or smaller than you, then you would enter its space, and bump into them and thus presumably know where they are. But you cannot attack them, this is because of the following rule:
Whether a creature is a friend or an enemy, you can't willingly end your move in its space...
As shown in this Q/A the quote above applies to your entire move, meaning you cannot make an attack while in another creature's space if you know that they are there. Thus you would first have to leave the creature's space in order to attack them.
An exception is if you were out of movement when you entered the creatures space. You did not know they were there and so this would not be a willing ending of your movement there, it just so happened that a creature was there when you ran out of movement. Thus you would be allowed to attack even while in its space.
This Q/A agrees with my claim that you would be allowed to do what you want with your action, and thus could attack the creature while in its space.
You can attack an invisible creature at disadvantage if you know where they are, otherwise you would have to guess their location.
You can attack an invisible creature even without having to run into it.
The invisible condition states:
An invisible creature is impossible to see without the aid of magic or a special sense. [...] The creature’s location can be detected by any noise it makes or any tracks it leaves.
Invisible is not the same as hidden as pointed out in the answer to this question.
Unless a creature is hidden, other creatures know the location of an invisible opponent without needing to make an ability check because "the creature’s location can be detected by any noise it makes or any tracks it leaves". Therefore you can attack an invisible creature without having to run into it in the first place, the attack just has disadvantage.