The extent to which the answer to your question is no is analysed by Milnor's exact sequence. You can write $M$ as the colimit of a sequence $M_n \subset M_{n+1}$ of cofibrations with $M_n$ compact (at least if $M$ is a manifold but much more generally). Then there is a "short exact sequence" of pointed sets $$ \{1\} \to \textstyle{\lim^1_n} [\Sigma M_n, N]_* \to [M,N]_* \to \lim_n [M_n,N]_* \to \ast $$ (in the usual sense that the map of pointed sets on the right is surjective and its fibers are orbits of the action of the group $\lim^1$ which acts on the set in the middle). Brayton Gray used this sequence to construct the example that Mark Grant mentions in the comments above in this paper (since $S^3$ is simply connected there is no difference between pointed and unpointed homotopy classes).
Another reference for the Milnor exact sequence is Bousfield and Kan, Homotopy Limits, Completions and Localizations, Corollary IX.3.3.
Edit Regarding the second question: under the assumptions, Milnor's exact sequence should provide$N$ has trivial homotopy groups, i.e. it is weakly contractible. Therefore, if it has the homotopy type of a counterexample but I don't immediately see an explicit onecell complex (for instance if it is a manifold) then it is contractible.