If $X$ is a non-compact metric space, can $X^n$ ever be compact?

Do there exist metric spaces $X$ such that $X^n$ is compact even though $X$ is not? Since compact spaces can have non-compact subspaces, e.g. $[0,1)\subset[0,1].$

• If $A \times B$ is compact (for the product topology), then both $A$ and $B$ are compact. – Watson May 12 '16 at 11:20
• I don't even know why I wrote that. – user339043 May 12 '16 at 11:20
• Yes, if $n=0$... – Johannes Huisman May 12 '16 at 14:58

No, since the image of a compact map by a continuous map is compact and the projection $p:X^n\rightarrow X$ is continuous and surjective.