The following is from https://stacks.math.columbia.edu/tag/00NS. I'm having some difficulty understanding some steps of the proof.
Let $R$ be a Noetherian local ring. Let $x \in \mathfrak m$. Let $M$ be a finite $R$-module such that $x$ is a nonzerodivisor on $M$ and $M/xM$ is free over $R/xR$. Then $M$ is free over $R$.
Let $m_1, \ldots , m_ r$ be elements of $M$ which map to a $R/xR$-basis of $M/xM$. By Nakayama's Lemma 10.20.1 $m_1, \ldots , m_r$ generate $M$. If $\sum a_ i m_ i = 0$ is a relation, then $a_ i \in xR$ for all $i$. Hence $a_ i = b_ i x$ for some $b_ i \in R$. Hence the kernel $K$ of $R^ r \to M$ satisfies $xK = K$ and hence is zero by Nakayama's lemma.
I take it that choosing some basis of $M/xM$ allows us to construct this homomorphism $R^ r \to M$, but I don't quite get how that works. I also don't understand why the kernel $K$ satisfies $xK=K$, nor why that implies $M$ is free.
The map $R^r \to M$ is given by choosing representatives $m_1,\dots,m_r$ of an $R/xR$ basis of $M/xM$, so $m_1+xM,\dots,m_r+xM$ is a $R/xR$ basis of $M/xM$. Letting $e_1,\dots,e_r$ be the standard basis of $R^r$ (or any basis really), we define $R^r \to M$ by $e_i \mapsto m_i$ for each $i$ and extending by linearity.
For the rest, $\sum a_ie_i$ is an arbitrarily chosen element of $K$. With $a_i=b_ix$, observe that $\sum a_im_i=x(\sum b_i m_i)=0$. But $x$ is a nonzerodivsor on $M$, so $\sum b_im_i=0$. This means $\sum b_ie_i \in K$, which shows $\sum a_ie_i=x(\sum b_ie_i) \in xK$, and we have $K=xK$. By Nakayama's lemma, $K=0$, so the map $R^r \to M$ is an isomorphism, and $M$ is free.