For retailers, the robot apocalypse isn’t a science-fiction movie. As digital giants swallow a growing share of shoppers’ spending, thousands of stores have closed and tens of thousands of workers have lost their jobs.

Belinda Duperre, who sold jewelry at Sam’s Club in Fall River, Mass., was one. In early 2016, the struggling store closed.

But...