It's a widely held misconception that crossbows have short range. That's only true of European crossbows with very short length of draw necessitated by their lever trigger design. The Chinese crossbow triggers are more like a modern mechanism which allows light trigger pull and full length draw, giving it similar range to the longbow using arrows like bolts.
However as mentioned in the previous post, the projectiles have a parabolic trajectory making hit probability more difficult the further away the target and the faster that target is moving.
Another factor is manufacture of ammunition. Bolts were produced by skilled fletchers. Producing bolts with consistent weight and shaft stiffness is quite complicated. Those who could mass produce this with high level of quality control had a significant advantage. In China it has been discovered the surviving bolt heads from the Qin dynasty were precision cast with quality control marks.
Compare that to a gun, the high velocity makes ammunition quality less critical. Early guns were loaded with stones or fired multiple pellets like shotguns. Later on they used cast lead, which was made by soldiers in the field over a campfire. This combination of simplicity in logisitcs and high hit probabilty was worth the trade off of the cost of powder and longer range.
Musket bullets might be easier to produce, but that's not the full package. The gunpowder was something of an issue for many groups to keep supplies ready. Did the Americans struggle to maintain supplies until the French got involved?