What is the best way to avoid constipation when taking narcotics?

Fluids. Drink more fluids at least one ounce per pound of body weight. Would also take MiraLAX (polyethylene glycol) while on narcotics. Miralax (polyethylene glycol) is over the counter. Easy directions.