The US trade deficit narrowed in October from a more than two-year high as companies dialed back imports of consumer goods and business equipment.