18. Given $z \in \mathbf{C}$, satisfying
$$
12|z|^{2}=2|z+2|^{2}+\left|z^{2}+1\right|^{2}+31 \text {. }
$$

Then the value of $z+\frac{6}{z}$ is ( ).
(A) -2
(B) -1
(C) $\frac{1}{2}$
(D) 1
(E) 4
18. A.
\[
\begin{aligned}
\text { Given } & 12|z|^{2}=2|z+2|^{2}+\left|z^{2}+1\right|^{2}+31 \\
\Rightarrow & 12 z \bar{z}=2(z+2)(\bar{z}+2)+\left(z^{2}+1\right)\left(\bar{z}^{2}+1\right)+31 \\
\Rightarrow & -10 z \bar{z}+4(z+\bar{z})+z \bar{z}^{2}+z^{2}+\bar{z}^{2}+40=0 \\
\Rightarrow & \left(z \bar{z}^{2}-12 z \bar{z}+36\right)+\left(z^{2}+2 z \bar{z}+\bar{z}^{2}\right)+ \\
& 4(z+\bar{z})+4=0 \\
\Rightarrow & (z \bar{z}-6)^{2}+(z+\bar{z}+2)^{2}=0 \\
\Rightarrow & z+\bar{z}=-2, z \bar{z}=6 \\
\Rightarrow & z+\frac{6}{z}=z+\bar{z}=-2 .
\end{aligned}
\]