JAKARTA—Indonesia's near trillion-dollar economy is at a crossroads as its presidential election approaches next week: Manufacturing wilted during a commodity boom that has now gone bust, and it badly needs to build ports, roads and power plants to reinvigorate growth.

A laborer unloads goods from a boat against the backdrop of a bridge under construction in Pekanbaru, on Indonesia's island of Sumatra, in March. Bloomberg News

Some economists warn the former darling of foreign investors has already missed its chance to avoid the "middle-income trap," a scenario where a fast-developing, resource-rich economy stalls out.

Both candidates—Jakarta Gov. Joko Widodo and former army general Prabowo Subianto —say they will push the huge projects and overhauls needed to deliver the country into a new economic era. But neither has laid out a detailed economic plan.

The resource-rich nation is a "gold mine in a minefield," cautions Andrew White, managing director of the American Chamber of Commerce in Jakarta, though he says it is now "rightly trying to find its way."

The reckoning has been a long time coming.

Throughout the 1990s, Indonesia built up its factories, and manufacturing's contribution to the economy reached 29% of gross domestic product in 2001 and 2002. Then, surging growth in China and other emerging economies drove up demand for Indonesia's palm oil, coal, bauxite and tin. Record commodity prices pushed companies to shift investment from manufacturing to the easier business of extracting the country's natural bounty.

In the process, Indonesia joined the ranks of the world's fastest-growing economies, expanding more than 6% three years in a row. Manufacturing, meanwhile, slipped to less than a quarter of GDP.

"Judging from how the manufacturing sector has played second fiddle to the 'dig-and-ship' model, Indonesia might have fallen into [the middle-income trap] already," said Wellian Wiranto, an economist at OCBC.

Indonesia is now straining to reverse the trend and build up such sectors as technology manufacturing. But many technology firms have decided against Indonesia in recent years.

One is BlackBerry Ltd. , then called Research In Motion, which despite its devices' enormous popularity in this market of 250 million people chose Malaysia instead for a regional manufacturing center. The reasons were a lack of tax incentives, infrastructure and skilled workers, according to an official at Indonesia's investment agency.

Samsung Group of South Korea also recently put plans for a cellphone factory on ice after Indonesia wouldn't offer regionally competitive incentives, according to government officials in Jakarta.

Such decisions worsen a trade deficit that has widened as Indonesia has raked in less for its commodities: For one thing, it imports billions of dollars' worth of cellphones each year.

Samsung and BlackBerry declined to comment on their investment decisions.

Taiwan-based Hon Hai Precision Industry Co. —the manufacturer also known as Foxconn that assembles most of Apple Inc. 's iPhones and iPads—has repeatedly delayed decisions on plans for factories in Indonesia, government officials say. Most recently, it missed an April target date to unveil details on the construction of a factory in Jakarta. Foxconn said it continues to consider investment in the country; it declined to comment on reasons for the delay.

There is still enthusiasm for Indonesia's potential: automotive companies including Toyota Motor Corp. and Nissan Motor Co. have been expanding factories here to market to a rising consumer class. After unrest in Thailand and elsewhere, others are weighing Indonesia's relative stability as an alternative.

But companies are also pointing to a history of gridlock when it comes to building sorely needed roads and electric grids.

"The roads are either bad or jammed, and the sea ports are packed. These kinds of things are undermining our competitiveness," said Suryo Suwignjo, president director of the local unit of Royal Philips Electronics NV.

The Dutch company, which makes items such as light bulbs and shavers in Indonesia, said it won't boost production until it sees action on infrastructure projects.

Domestic car and motorcycle maker Indomobil Sukses Internasional complains of high land prices around Jakarta but says it is hard to set up manufacturing elsewhere.

"You may want to move to Semarang," a city on the main island of Java where wages are lower and land is available, but "the infrastructure just isn't enough," said Soebronto Laras, a top company executive.

Particularly troubling for foreign investors is a perception that the reluctance to offer incentives such as tax breaks has grown in the wake of the commodities boom. A popular refrain among politicians of all stripes is that Indonesia missed out by sending "boatloads of dirt" overseas rather than refined minerals.

It is unclear which of the candidates would most strongly address such complaints or how far any measures would get in a fractured parliament. Some economists say Mr. Widodo's talk of cutting red tape sounds more practical than Mr. Subianto's vision of radically higher growth through new processing industries and better tax collection, among other things. Many foreign businesses say they just want someone to make decisions, and help alleviate investment uncertainty stemming from unclear and changing regulations.

For investors, the clearest signal of change will be how quickly a new president moves to rein in fuel subsidies costing billions of dollars.Tackling the subsidies has been politically unpopular and has led to nationwide protests in the past. Messrs. Widodo and Subianto both say they will wean the country off the aid to leave more money for infrastructure projects.

"Both candidates have promised the moon when it comes to how many kilometers of road to be built," said Mr. Wiranto, the OCBC economist. "The problem is both funding and land acquisition."

Foreign direct investment in Indonesia hit a record last year, but its growth has slipped, and at less than 3% of GDP, it lags regional powers like Singapore at more than 20% and Malaysia at more than 5%.

"We know the country cannot rely on only commodities and energy," said Finance Minister Chatib Basri, who has pushed other ministries for reforms. "We don't want to fall into the middle-income trap."

"This is about how the country survives in the long term," he said.

"It's a little late for Indonesia to catch up to regional peers, but it must develop its manufacturing sector, and it has to be done now," said Aldian Taloputra, chief economist at Mandiri Sekuritas, a Jakarta-based investment bank. Thailand's manufacturing accounted for almost 36% of GDP in 2010, according to the World Bank.

The bank also signaled that the moment is now for Indonesia, saying in a report last week, "Indonesia cannot afford to not try harder."

Write to Ben Otto at ben.otto@wsj.com and I Made Sentana at i-made.sentana@wsj.com