しかないんだ

have no choice but to

→ しか
phrase Uncommon #19,318
have no choice but to After a verb, it means there is no alternative but to do it. With a noun, しかない means “there is only.” んだ adds an explanatory tone; んです is the polite form.
JA: もう帰るしかないんだ。
EN: I have no choice but to go home now.

ここにいるしかないんだ

I have no choice but to stay here.

— 罪人たち (2025)

冷蔵庫には牛乳しかないんだ。

There's nothing in the fridge but milk.

もう要石を刺すしかないんだ

Now we have no choice but to drive in the keystone.

— すずめの戸締まり (2022)

汚れてないのこれしかないんだ

This is the only one that isn’t dirty.

— ハウルの動く城 (2004)