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$.
If $X$ is arbitrarily singular, the same theorem holds, provided $X$ is irreducible. This was shown by Karčjauskas for algebraic varieties and by Hamm for Stein spaces.