This is the actual solution, and I'm not sure why I'm getting so many downvotes from it. Clearly, purely capitalist markets aren't enough to sustain a decent pharmaceuticals industry.
In which world is the Chinese market not capitalist? Chinese drug exports are absolutely for-profit. They don't export out of philanthropy. It's probably even worse than elsewhere!
Fentanyl is manufactured for medical use in the massive and extremely lucrative US market. The fact that American drug cartels import it for sale on the black market is an unfortunate side-effect.
The solution to the opioid epidemic is stupidly simple: enable safe supply so that addicts don't have to destroy their lives in pursuit of their addiction. That, by the way, is an addiction created by US pharmaceutical companies forcing doctors to overprescribe opioids despite knowing how addicting they are.
China doesn't have to wage shadow warfare when the US is happy to do so to itself.