5. If there exists a complex number $z$ with a modulus of 1, such that
$$
z^{2}+a z+a^{2}-1=0,
$$

then the real number $a$ has $\quad$ possible values.
5.5.

Consider the quadratic equation in $x$
$$
x^{2}+a x+a^{2}-1=0 \text {. }
$$

Its discriminant $\Delta=a^{2}-4\left(a^{2}-1\right)=4-3 a^{2}$.
(1) When $\Delta \geqslant 0$, i.e., $-\frac{2 \sqrt{3}}{3} \leqslant a \leqslant \frac{2 \sqrt{3}}{3}$, the equation
(1) has real roots.

Let the expression on the left side of equation (1) be the function $f(x)$. If the complex number $z$ that satisfies the condition is real, then at least one of $f(1)$ and $f(-1)$ equals 0.

And $f(1)=a(a+1), f(-1)=a(a-1)$, so when $a \in\{0,1,-1\}$, there exists a complex number $z$ (i.e., 1 or -1) that satisfies the condition.
(2) When $\Delta<0$, i.e., $a<-\frac{2 \sqrt{3}}{3}$ or $a>\frac{2 \sqrt{3}}{3}$, equation (1) has two conjugate complex roots, denoted as $z$ and $\bar{z}$.
By Vieta's formulas,
$a^{2}-1=z \bar{z}=|z|^{2}$.
Let $|z|=1$, solving gives $a= \pm \sqrt{2}$.
Upon verification, $a= \pm \sqrt{2}$ also satisfies the condition.
In summary, there are 5 possible values for the real number $a$ that satisfy the condition.