I don't know what the cheapest way is, but my bet is using a shared container heading to the port of Colon in Panama. It's the busiest container port in the region and lots of boats from the US east coast head for the west coast, crossing the Canal.
That said, I think it's the cheapest.
Shipping to Nicaragua direct might be difficult. As far as I know, they don't have a deep port. Costa Rica has one at Puerto Limon on the Atlantic side.
Other than by sea, you can ship by air to either Panama or Nicaragua, and here prices depend on volume of goods shipped on the route. I would still bet on Panama for being cheaper, as it is a major transportation hub in the region.
Of course you then need to factor in the cost of driving from Panama to Nicaragua.