There's a fairly standard proof that the rank of a free module $F$ over a commutative ring $R$ is well defined. We take a maximal ideal $I$ and note that $R/I$ is a field. Taking $R/I \otimes_R F$ gives a vector space of dimension rank of $F$, which gives the result.
I was wondering where the proof breaks down in the non-commutative case (let's assume we have a unit). According to the wikipedia article on Division Rings, every module over a division ring is free with well-defined rank, and I don't see any issue with taking a maximal ideal (do we need to be careful with selecting maximal left/right/two-sided ideals?) or with taking the tensor product. If someone could point out what's wrong that would be greatly appreciated.
The flaw is that if $I$ is a maximal ideal in a noncommutative ring, $R/I$ need not be a division ring (here "ideal" should mean two-sided ideal, since otherwise $R/I$ won't even be a ring at all). The usual proof for commutative rings is that if $r\in R$ is not a unit, then the ideal generated by $r$ is a proper ideal (since it just consists of the multiples of $r$ and $1$ is not a multiple of $r$), and thus if a ring has no nonzero proper ideals it is a field. But for noncommutative rings, the (two-sided) ideal generated by a single element $r$ is much more complicated: it is the set of all sums of elements of the form $arb$ for $a,b\in R$. Note that for instance, there is no way to write a sum like $arb+crd$ as a single two-sided multiple of $r$ in general. So even if $1$ is not a multiple of $r$, $1$ might be in the ideal generated by $r$.