You would think that a guy who has spent decades with his nose in a book ought to be used to radical social distancing, to being alone day after day. In fact, the past two weeks have been hard. Not, let me hasten to say, as hard and stressful as they have been for our hospital nurses, physician assistants and doctors. They are the real heroes and heroines of these nightmarish times. My eldest son is one of them, and I worry about him a lot.

While sheltering in place, as we all should be doing, I’ve sought temporary respite from anxiety by reorganizing the garage and culling the Smaug’s hoard that passes for my library. Every evening, though, I find myself considering a second beer until I think, “Why stop at two?” At night, staring into the darkness, I frequently recall far too many friends, colleagues and relatives who now live, often quite vividly, only in my memory. Given half a chance, I can grow impressively maudlin.

Nonetheless, I confess to particular sympathy for parents currently trapped at home with their young children. These formerly competent, levelheaded adults must be going quietly insane. Denied playdates and the regimen of school, even normally well-behaved kids soon grow fractious, then belligerent and, before you know it, as frenzied as the feral, rampaging castaways in “Lord of the Flies.”

Pascal famously said that all our miseries derive from our inability to sit quietly alone in a room. “All our miseries” is certainly an exaggeration, but there’s no doubt that human beings are, at heart, social animals. We like parties. We herd ourselves into sports arenas and rock concerts. Inexplicably, we even attend political rallies. Little wonder that Charles Mackay’s “Extraordinary Popular Delusions and the Madness of Crowds” has been a steady seller for more than 150 years.

Still, aren’t there books that might help us cope with isolation and long periods of self-quarantine, that could even show us how we might thrive, not just survive, as involuntary shut-ins?

The first work that immediately comes to mind is — no surprise — Daniel Defoe’s survivalist bible “Robinson Crusoe,” quickly followed by explorer Richard E. Byrd’s polar classic, “Alone,” the record of five months by himself in a tent in Antarctica, and then Lucy Irvine’s “Castaway,” her 1983 account of an emotionally vertiginous year subsisting on a remote tropical island. In “Walden” Thoreau contends that society’s hurly-burly distracts us from what truly matters: “I went to the woods because I wished to live deliberately, to front only the essential facts of life, and see if I could not learn what it had to teach, and not, when I came to die, discover that I had not lived.”

That notion of self-exploration and spiritual renewal runs through the vast literature of incarceration. Witness John Bunyan, who began “The Pilgrim’s Progress” during a 12-year prison sentence or Jean Genet, who produced his subversive masterpiece, “Our Lady of the Flowers,” while he was behind bars. Locked away in a Massachusetts’s penitentiary, Malcolm Little nevertheless remade himself through study and faith, later telling his conversion story in “The Autobiography of Malcolm X.” In Jack London’s “The Star Rover” a death-row inmate discovers the trick of freeing his spirit and sending it back to relive his previous incarnations.

Some of our most popular children’s books focus on young people forced to fend for themselves. In 1961 the Newbery Medal was awarded to Scott O’Dell’s classic “Island of the Blue Dolphins,” about the Native American girl Karana, stranded for years on a Pacific island. In Gary Paulsen’s 1986 Newbery Honor book a 13-year old boy confronts the Canadian wilderness with nothing but the tool that gives the novel its thrilling title, “Hatchet.” One of William Steig’s best picture books, “Abel’s Island,” relates the adventures of a mouse turned Rodent Crusoe.

Constraint, paradoxically, often liberates the imagination. In Josephine Tey’s masterpiece “The Daughter of Time,” Inspector Alan Grant passes a long bed-bound convalescence by reassessing the evidence that Richard III murdered the two sons of Edward IV, the “Princes in the Tower.” Confined to his lodgings after fighting a duel, Xavier de Maistre composed the parodic 1794 guidebook, “A Journey Around My Room,” in which he “visits” his furniture, artworks and library as if they were fashionable tourist attractions on a miniaturized Grand Tour. In J.K. Huysmans’s “Against the Grain,” the ultra-decadent Des Esseintes retreats from crass, bourgeois society to a specially designed house in the country, his own artificial paradise. The imagination, he affirms, can “provide a more-than-adequate substitute for the vulgar reality of actual experience.”

Still, there are dangers attached to extreme nesting. In E.M. Forster’s short story “The Machine Stops,” first published in 1909, people reside in separate hive-like cells deep underground and rely almost entirely on screens to communicate with one another. A vast, unseen technology attends to everyone’s needs. But when its machinery starts to break down, chaos quickly ensues since the humans have grown wholly reliant on their technology god.

“Hell,” concluded Jean-Paul Sartre in his three-person play “No Exit,” “is other people.” Perhaps that’s why the most ardent heaven-seekers — mystics, monks and sages — spend so much time alone, praying in the wilderness or meditating on mountaintops. In Flaubert’s drama-like novel, “The Temptation of Saint Antony,” an ascetic anchorite struggles against theological doubts and the carnal enticements of the gorgeous Queen of Sheba: “I am not a woman, I am a world. . . . The possession of the least part of my body will fill you with a joy more vehement than the conquest of an empire.”

The virtuous hermit firmly rejects these exceptionally attractive, albeit satanic blandishments. That’s the kind of iron will you can develop after a couple of decades living by yourself, far from the madding crowd. Antony, as it happens, is the saint charged with protection against infectious diseases. We could sure use his help now.

Michael Dirda reviews books each Thursday in Style.