New York CNN Business  — 

General Motors (GM) reported record earnings for 2021, despite struggling with a shortage of computer chips and other parts that crimped its ability to build and sell all the cars and trucks it wanted.

Quarterly earnings reached nearly $2 billion, excluding special items, topping the consensus forecast of $1.7 billion from analysts surveyed by Refinitiv. That allowed the company to earn $10.4 billion for the year, excluding special items, up from $7.1 billion a year earlier.

The company achieved those results despite being forced to temporarily close various factories throughout the year due to the industry-wide parts shortage. The number of vehicles it sold fell to 6.3 million worldwide, down 8% from 2020 and a decline of 18% from the pre-pandemic sales of 2019.

That slump in sales resulted in GM giving up its spot as the No. 1 automaker in terms of US sales, a position it held for nearly a century through the Great Depression, wars, numerous recessions and its own 2009 bankruptcy and federal bailout.

The company said it expects the supply of computer chips to improve this year, but nevertheless gave conservative guidance for 2022 sales and profit similar to this year’s results.

GM is attempting to shift its production from traditional internal combustion engine vehicles to electric vehicles by 2035, and has said it plans to build one million EVs by 2025. CEO Mary Barra told journalists Tuesday that she thinks demand for the EVs will be higher than that, with models that will include a Hummer EV that just went into production, the Cadillac Lyriq, due later this year, and EV versions of its best-selling Silverado and Sierra pickups by 2024.

The company said it has reservations from customers for 59,000 of the Hummer EVs and 110,000 of the Silverado EVs.

GM has committed to invest $35 billion in the effort by 2025, including $7 billion for Michigan plants announced last week.

Barra said that while the company is considering restoring the dividend that it suspended in April 2020 during the depths of the pandemic-related recession, it will not take that action yet.

“Our clear priority is to accelerate our EV plan and drive growth, and we want to maintain maximum flexibility to invest as opportunities arise,” she said.

The company is also facing the challenge of developing still unproven technology to allow for autonomous driving vehicles, a costly conversion.

Making that change to its EVs and autonomous vehicles as the industry is still shaking off the effects of the pandemic and supply chain issues will be especially challenging, said Karl Brauer, executive analyst for iSeeCars, a car shopping site.

“The company’s profitability in recent years is encouraging, but its continued decline in sales and market share is not,” said Brauer. “Getting those customers back could prove difficult as the industry undergoes massive disruption.”

The company’s profitability will mean that 42,500 members of the United Auto Workers at GM will get profit sharing payments of up to $10,250. The members received $9,000 in profit sharing a year ago.

GM shares were slightly higher in after-hours trading following the results.

Correction: A previous version of this article misquoted the number of United Auto Workers members at GM who will receive profit sharing payments. 42,500 members of UAW at GM will receive the payments.