Using Nakayama's Lemma to prove isomorphism theorem for finitely generated free modules Suppose $R \neq 0$ is a commutative ring with $1$. The following is well known:

(Isomorphism Theorem for Finitely Generated Free Modules) [FGFM] $R^{n}\cong R^{m}$ as
  $R$-modules if and only if $n=m$.

One proof of this result (if I recall correctly) was somehow based on the idea that we can quotient out by a maximal ideal of $R$ (whose existence is guaranteed by Zorn's Lemma), and reduce the situation to that of vector spaces. However, I am interested in different approach. Recall 

(Nakayama's Lemma) Suppose $M$ is a finitely generated $R$-module, and
  $M=IM$ where $I$ is an ideal contained in Jacobson radical of $R$. Then, $M=0$.

My question is: 

Can we prove FGFM using Nakayama's Lemma?

My main motivation in asking this question is two-fold:
1) to see the power and usefulness of Nakayama's Lemma, and
2) to see a nice and short proof of FGFM that does not involve reducing the problem to a result from linear algebra.
I appreciate any input :)
 A: Here's one idea. Use the following consequence of Nakayama:

If $M$ is a finitely generated $R$-module and $f\colon M\to M$ is a surjective module homomorphism, then $f$ is an isomorphism.
Proof: View $M$ as an $R[x]$-module, where the action of $x$ on $M$ is given by $f$. By assumption $xM = M$. The proof of Nakayama's lemma then gives that there is some element $P(x)\in R[x]$ such that $(1 - P(x)x)M = 0$. Then for any $m\in M$, $$0 = (1 - P(x)x)m = m - P(f)(f(m))\implies m = P(f)(f(m)).$$ This shows that $P(f)$ is an inverse of $f$. 

To use this to prove FGFM, do the following. Suppose $n\geq m$, and that $R^n\cong R^m$. First, fix a basis $e_1,\ldots, e_n$ of $R^n$, and identify $R^m$ with the submodule of $R^n$ generated by $e_1,\ldots, e_m$, so $R^m\subseteq R^n$. Let $\pi\colon R^n\to R^m$ be the projection map. Since by assumption $R^n\cong R^m$, there is some isomorphism $f\colon R^m\to R^n$. But then $\pi\circ f\colon R^m\to R^m$ is surjective, and hence by the result above, is also an isomorphism. However, since $f$ is surjective, the only way that $\pi\circ f$ can be an isomorphism is if $\pi$ is injective. This of course only happens when $n = m$.
