Small cities in the Midwest and Northeast are particularly vulnerable. When major industries left town, retail accounted for a growing share of the job market in places like Johnstown, Decatur, Ill., and Saginaw, Mich. Now, the work force is getting hit a second time, and there is little to fall back on.

Moreover, while stores in these places are shedding jobs because of e-commerce, e-commerce isn’t absorbing these workers. Growth in e-commerce jobs like marketing and engineering, while strong, is clustered around larger cities far away. Rural counties and small metropolitan areas account for about 23 percent of traditional American retail employment, but they are home to just 13 percent of e-commerce positions.

E-commerce has also fostered a boom in other industries, including warehouses. But most of those jobs are being created in larger metropolitan areas, an analysis of Census Bureau business data shows.

Almost all customer fulfillment centers run by the online shopping behemoth Amazon are in metropolitan areas with more than 250,000 people — close to the bulk of its customers — according to a list of locations compiled by MWPVL International, a logistics consulting firm. An Amazon spokeswoman noted, however, that the company had recently opened warehouses in two distressed cities in larger metropolitan areas, Fall River, Mass., and Joliet, Ill.