John Bolton (from left), Johnny Rabe, Erin Dilly and Zac Ballard help light up the holidays in a fun musical version of the ’83 film. Photo: Carol Rosegg

Writing a musical is hard. Writing a musical based on a movie with a passionate cult following is harder yet. A lot of your customers are going to feel personally betrayed by any change to what’s playing in their head.

Fans of “A Christmas Story” can breathe easy: The charming musical that opened last night on Broadway, after touring the Midwest last year, succeeds both as an adaptation and on its own terms.

Joseph Robinette’s book faithfully transposes to the stage the adventures of 9-year-old Ralphie (Johnny Rabe), who dreams of landing a Red Ryder Carbine Action BB gun for Christmas. It probably helped that Peter Billingsley, who played Ralphie in the 1983 flick, is one of the show’s producers.

But even those who’ve somehow managed to miss the film are likely to enjoy the show. This is a sweet, funny holiday outing, the rare family entertainment that doesn’t feel like a soulless, dumbed-down corporate product. Even the obligatory merchandise — leg lamps and all — looks good.

Like its inspiration, the nostalgic “A Christmas Story, the Musical” looks back on life in an idealized 1940 Indiana town with equal parts warmth and rambunctious humor.

As in the movie, which he narrated in voice-over, our guide is Jean Shepherd, the late writer and radio personality whose book inspired the script. Here he’s played by Dan Lauria, whose stint on “The Wonder Years” made him one of the most popular TV dads ever.

As Shepherd, Lauria provides a dry running commentary, helping link the disparate vignettes that make up the plot.

And except for the Ovaltine gag, they all turn up: Ralphie lets out a swear while helping the Old Man (John Bolton) change a tire, Mother (Erin Dilly) goads little Randy (Zac Ballard) into eating his meatloaf like the Little Piggies, Flick (Jeremy Shinder) gets his tongue stuck on a frozen flagpole, and the Bumpus hounds chase Ralphie’s dad across the stage, before demolishing his Christmas turkey.

The new material is perfectly incorporated into the familiar frame, most notably Benj Pasek and Justin Paul’s zippy score, which is old-fashioned in the best way possible. You may have “Ralphie to the Rescue!” stuck in your head for a while.

Choreographer Warren Carlyle and director John Rando keep things moving at a brisk pace. They’ve surrounded the cast’s many children with excellent adult pros, and it’s a treat to see generations mingle in numbers like “You’ll Shoot Your Eye Out.”