VILNIUS, Lithuania – Many developed countries have anti-immigration political parties. Lithuania is unusual in having an anti-emigration party.

The small Baltic country, with a population of 2.8 million and falling, voted heavily in 2016 for the Lithuanian Farmer and Greens' Union, which pledged to do something to stem the outward tide. As with some promises made elsewhere to cut immigration, not much has happened as a result.

"Lithuanians are gypsies, like the Dutch," said Andrius Francas of the Alliance for Recruitment, a jobs agency in Vilnius, the capital.

Workers began to drift away almost as soon as Lithuania declared independence from the Soviet Union in 1990. The exodus picked up in the new century, when Lithuanians became eligible to work normally in the European Union. For many, Britain is the promised land.

Mostly because of emigration, the number of Lithuanians aged between 15 and 64 fell from 2.5 million in 1990 to 2 million in 2015. The country is now being pinched in another way. Because its birthrate crashed in the early 1990s, few are entering the workforce. The number of 18-year-olds has dropped by 33 percent since 2011. In 2030, if United Nations projections are correct, Lithuania will have just 1.6 million people of working age.

Lithuania was an early member of a growing club. Forty countries now have shrinking working-age populations, defined as 15- to 64-year-olds, up from nine in the late 1980s. China, Russia and Spain joined recently; Thailand and Sri Lanka soon will. You can now drive from Vilnius to Lisbon (or eastward to Beijing, border guards permitting) across only countries with falling working-age populations.

It need not always be disastrous for a country to lose people in their most productive years. But it is a problem.

A place with fewer workers must raise productivity even more to keep growing economically. It will struggle to sustain spending on public goods such as defense. The national debt will be borne on fewer shoulders. Fewer people will be around to come up with the sort of brilliant ideas that can enrich a nation. Businesses might be loath to invest. In fast-shrinking Japan, even domestic firms focus on foreign markets.

The old will weigh more heavily on society, too. The balance between people over 65 and those of working age, known as the old-age dependency ratio, can tip even in countries where the working-age population is growing.

There are three policies that can greatly alleviate the effects of a shrinking working-age population.

The first is to encourage more women to do paid work. University-educated women of working age outnumber men in all but three E.U. countries, as well as the U.S. and (among the young) South Korea.

Yet female participation in the labor market lags behind men's in all but three countries worldwide.

Countries can also make better use of older workers. Ben Franklin, of ILC UK, a think tank, argues that 65, a common retirement age, is an arbitrary point at which to cut off a working life. And in many countries even getting workers to stick around until then is proving difficult.

A final option is to lure more migrants in their prime years. Working-age populations are expected to keep growing for decades in countries such as Australia, Canada and New Zealand, which openly court qualified migrants. Others can try to entice foreign students and hope they stick around.

The trouble is that the countries with the biggest demographic shortfalls are often the most opposed to immigration.