A new report shows that emissions from producing large battery packs for electric cars could cancel out improvements from their low emissions for years.

The report comes from Bloomberg New Energy Finance, which is usually optimistic about electric cars. In May, the analytic arm of the finance publishing house predicted that electric cars will make up half the global market by 2040. 

The problem, BNEF notes, is that the places that build batteries for electric cars around the world use among the dirtiest energy. Those places include China, Thailand, Germany, and Poland, the report says.

READ THIS: Electric cars will exceed half the market and displace 7 percent of gasoline consumption by 2040: report

It is compounded by the fact that the latest electric cars come with bigger and bigger batteries. For its report, BNEF used a battery size of 60 kilowatt-hours, about the size of that in the Chevy Bolt EV, with its 238-mile electric range. 

Cars with bigger batteries may have an outsize impact on factory pollution and may take more years and miles of driving to make up for the extra emissions produced in building their batteries.

A 2014 study from the University of California, Irvine noted the same phenomenon.

Energy sources for battery production, by country [CREDIT: Bloomberg]

Energy sources for battery production, by country [CREDIT: Bloomberg]

Although Germany is known for having one of the fastest-growing solar energy industries in the world, the country still gets between 22 percent and 37 percent of its energy from coal, and more where battery factories are located.

Consulting firm Berylls Strategy Advisers notes that for a 30-kwh Nissan Leaf will take three years of driving in Germany before it makes up for the extra pollution created in building its battery. 

CHECK OUT: Electric cars emit less carbon than average U.S. new car, everywhere in the world

The way to fix the problem, BNEF notes, is for automakers to use more renewable power at battery factories, citing the solar-powered Tesla Gigafactory in Nevada, and the giant Northvolt factory being built in Sweden, which plans to use hydro-power.

Another option could be building more plug-in hybrids with smaller batteries that still do most driving on electricity and are very efficient when using gasoline.

At the Paris auto show earlier this year, Daimler board member Ola Källenius, who is expected to take over as CEO next year, told Bloomberg, "By 2030, the life cycle [emissions of battery-electric cars] will improve."