The companies that feed America and provide basic staples are bracing for labor shortages as the novel coronavirus pandemic intensifies, which could leave them without enough workers to manufacture, deliver and unpack groceries in stores in the coming months. As the virus spreads, supermarkets and distribution facilities face a difficult choice: how to keep shelves stocked with essentials while keeping their workers safe. Already, some chains are rationing products as shelves empty out of pasta, rice and frozen vegetables and anxious customers wait in long lines for toilet paper and bottled water — in scenes similar to those seen before a hurricane, yet this time unfolding on a national scale.

In Washington, D.C., hundreds of people waited in lines that snaked to the back of stores and sometimes onto sidewalks at Walmart, Whole Foods and Trader Joe’s this week, as consumers stocked up on toilet paper, canned tuna and cartons of premade soups. Cases of chicken, beef and frozen vegetables were largely wiped out at a Whole Foods near American University. At the Trader Joe’s in Tampa, the pasta and tomato sauce aisle was empty Friday afternoon, and the salty snacks were depleted (there was still plenty of $3 chardonnay on offer, however).

Food producers and supply chain managers say there is generally enough nonperishable food on shelves, in warehouses and on the production line to last several months, but the challenge could soon be getting that food to the right places once local distribution centers are wiped out. In addition, millions of Americans who previously got food at restaurants or in school or at work cafeterias will have to serve themselves at home, with food bought from grocery big-box enterprises.

“The replenishment cycle is going to be the real test here,” said Sean Maharaj, a supply chain expert and managing director at AArete, a consulting firm in Chicago. “Manufacturers don’t sit on a lot of extra inventory, so what do you do when everything you have is depleted?”