namespace foo {
class Bar ...
}
In another file declare namespace foo {
class Bar ...
}
Now use both foo.Bar from file 1 and foo.Bar from file 2 in the same project. Aliases don't help with thisDifferent assemblies with different assembly names but same namespace and class? Just use the fully qualified type name (and alias it for a shorter name).
Single assembly/project and namespace with the same class in multiple files? If you're just spreading out the code then use partial classes, otherwise why would you define the same type twice?
C# (and other languages) that use virtual namespaces can do everything that file-based namespaces can do, but also support many more scenarios.
There is one gazillion things that are much more a problem than "namespace conflicts" in packaging and package management.
Including security & code authenticity, parallel multi-version handling, sensibility to side effects, speed, auditing and reproducibility.
And in these domain the JavaScript packaging system generally range from being 'catastrophic' to 'absolutely terrible'.
If I have to take an example package management system for the world I would certainly quote cargo, Nix, Guix or Spack but certainly not npm which is quite close to what you should really not do for a package manager.
All of those the space of namespaces is global. You can't have 2 modules named math.quaterinions in any of those languages. You can in JavaScript. To put it another way, in order to prevent name clashes in C++/C#/Java you have to know the name of every other project on the planet. If someone uses the same namespace then if you ever need to use those 2 projects together one of them will have to be re-factored.
That problem doesn't exist in modern JavaScript. There are no namespaces. There is just floating references to code.