If $X$ is smooth, and if you ask to have the same homotopy type of a CW complex of real dimension *at most* $n$, this is precisely the statement of the Andreotti-Frankel theorem. It is true, more generally, for a Stein manifold of complex dimension $n$.