Artificial intelligence (AI) investing is somewhat affected by tariffs, as tariffs may be placed on components coming into the U.S. In addition, broader consumer demand may harm some of the cash flows that are being poured into AI investments.

I've got a few stocks that will be fine over the long term, regardless of what happens with tariffs. These are excellent stocks to scoop up now and should be purchased with the mindset of holding for three to five years.

The American flag.

Image source: Getty Images.

Meta Platforms

Meta Platforms (META -1.16%) is an advertising company that earns most of its revenue (98%) from ads on social media platforms like Facebook and Instagram. It uses the enormous cash flows from its base business to heavily invest in AI, which allows it to innovate in the ad realm and develop new technologies.

Tariffs may hurt Meta's primary business by causing some economic headwinds, which could affect advertising revenue streams. However, that will only be an initial shock, and while it could be a bumpy year or two, Meta's base business will be just fine over the next three to five years.

Over that time frame, there will undoubtedly be impressive AI developments, likely including Meta's AI glasses, which could become an important part of the Meta investment thesis if they become a hit. Regardless, I think there's a strong enough case for the base business to purchase Meta shares right now, no matter what happens with tariffs.

Meta is also fairly priced. Although it would have been better to buy it a few weeks ago when the markets bottomed, it's still priced at the lower end of where it has traded over the past year.

META PE Ratio Chart

META PE Ratio data by YCharts

Even though the market roared back, I think Meta still makes a compelling enough long-term investment to take a position in the stock now.

Nvidia

Nvidia (NVDA -1.70%) may be a surprise addition to this list, as it sources many of its chips from outside the country. However, Nvidia announced that its next-generation Blackwell GPUs will be produced entirely in the U.S. by 2026. With chips originating from Taiwan Semiconductor Manufacturing's Arizona facility and then assembled in Foxconn and Wistron plants in Texas, these GPUs won't be subject to tariffs, because they're domestically produced.

Nvidia's GPUs will still be in high demand over the next few years, as the AI hyperscalers are still working on building out their data center capacity. Furthermore, many GPUs originally purchased to train AI models will start to wear out, requiring Nvidia's customers to replace them. Third-party estimates pegged 2024 data center capital expenditures at $400 billion, but they're expected to rise to $1 trillion by 2028. This expansion will further bolster Nvidia's growth, making it a strong stock to buy (or at least continue holding).

Like Meta's stock, Nvidia's dramatically recovered but is still below where it traded for most of 2024.

NVDA PE Ratio (Forward) Chart

NVDA PE Ratio (Forward) data by YCharts

At 31 times forward earnings, Nvidia isn't necessarily cheap, but the future looks bright enough for the company that it would be smart to scoop up shares now.