Artificial intelligence (AI) shares have been under pressure recently, with investors becoming increasingly concerned about the enormous amount of money being spent on data centres and computing infrastructure.
And I can understand why. Building AI infrastructure is expensive, and there's still uncertainty about how quickly companies will generate returns on those investments.
However, I believe the long-term growth opportunity remains enormous.
And there are three ASX shares I'd consider buying while investors are nervous.

Image source: Getty Images
Goodman Group (ASX: GMG)
My first pick is Goodman, which I think is exceptionally well-positioned to benefit from growing demand for data centres.
One of the biggest challenges facing the industry is securing suitable land and sufficient electricity to operate these enormous facilities.
Goodman doesn't have this problem. The company already owns valuable sites across major global cities, many of which are suitable for data centre development.
It has built a potential data centre power bank of approximately 6.6 gigawatts, including 3.6 gigawatts of secured power. I believe that's a valuable position to occupy as technology companies compete for access to suitable locations.
And Goodman is already turning these opportunities into earnings. In FY26, its operating profit increased 15.7% to $2.67 billion, supported by its expanding data centre development business.
I think Goodman has an excellent opportunity to become a much larger data centre developer over the coming decade.
The shares carry a premium valuation, and development delays are a risk, but I'd happily buy for the long term.
Megaport Ltd (ASX: MP1)
Another ASX AI share I'd buy is Megaport, which I believe could be one of the biggest beneficiaries of growing investment in AI infrastructure.
The company originally built its business around helping enterprises connect to cloud providers and data centres. However, its expansion into computing infrastructure through Latitude.sh has opened up another growth opportunity.
Megaport is now supplying the computing power and infrastructure that customers need to run AI workloads. And demand appears strong.
In September, the company announced almost $1 billion in additional AI infrastructure contracts, taking the total value of strategic contracts announced since April to approximately $2.3 billion.
These agreements are expected to help lift pro forma annual recurring revenue (ARR) to around $1.1 billion once the contracted services are deployed. I think that's impressive progress.
The challenge will be converting those contracts into profitable revenue while managing the enormous investment required in GPUs and other equipment.
However, I believe Megaport could become a much larger business if it executes its strategy successfully.
NEXTDC Ltd (ASX: NXT)
My final ASX AI share to buy is NEXTDC, which has experienced significant share price volatility recently.
The company suffered a major sell-off in October after electricity supply delays at its M3 Melbourne facility forced management to cut FY27 earnings guidance.
That was a significant setback, and investors are understandably concerned about further delays and development costs.
However, I think the longer-term opportunity remains attractive. At the end of FY26, NEXTDC had approximately 740 megawatts of contracted capacity, but only 175 megawatts was generating revenue.
I believe bringing the remaining capacity online could support a major increase in earnings over the coming years.
And there has been an interesting development. Goodman and Digital Realty (NYSE: DLR) recently acquired a combined 9.9% stake in NEXTDC.
I think this demonstrates that experienced data centre investors recognise value in NEXTDC's assets.
I'd consider NEXTDC as a relatively high-risk investment because of what has been going on, but I believe the potential rewards are considerable.
Foolish takeaway
I think the recent AI sell-off could create opportunities for investors willing to look beyond short-term uncertainty.
Goodman, Megaport, and NEXTDC each have the potential to benefit from growing demand for computing infrastructure.
And while their risks differ, I'd be happy to buy all three ASX AI shares with a long-term investment horizon.