5. Given the equation about the real number $x$: $(1+\mathrm{i} x)^{n}=$ (1-ix)"A (where $A \in \mathbf{C}, n \in \mathbf{N}_{+}$) has exactly one solution. Then $\Lambda$ $n$ satisfies ( ).
(A) $|A|=1, n \in \mathbf{N}_{+}$
(B) $|A|=1, n=1$ or 2
(C) $A=1, n \in \mathbf{N}_{+}$
(D) $|A|=1, A \neq-1, n=1$
5.D.

Let $x=\tan \alpha, \alpha \in\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$. Then
$$
\begin{array}{l}
A=\left(\frac{1+\mathrm{i} x}{1-\mathrm{i} x}\right)^{n}=\left(\frac{\cos \alpha+\mathrm{i} \sin \alpha}{\cos \alpha-\mathrm{i} \sin \alpha}\right)^{n} \\
=(\cos 2 \alpha+\mathrm{i} \sin 2 \alpha)^{n}=\cos 2 n \alpha+\mathrm{i} \sin 2 n \alpha,
\end{array}
$$

we know that $|A|=1$.
Let $A=\cos \theta+\mathrm{i} \sin \theta, \theta \in[0,2 \pi)$.
Then $2 n \alpha=\theta+2 k \pi(k \in \mathbf{Z})$.
Since there is only one solution in $\left(-\frac{\pi}{2}, \frac{\pi}{2}\right)$, and $\alpha=\frac{\theta}{2 n}+$
$\frac{k \pi}{n}$, then $n=1, A \neq-1$.