Ring A is a field iff every A-module is free. [duplicate]

This question is from my Algebraic Geometry assignment and I was unable to solve this:

Let A be a non-zero commutative ring. (a) Prove that the ring A is a field if and only if every A-module is free.

Attempt: Let ring A is a field and let I have an A-module X then I have to prove that X is free ie there exists an basis for X. X is an A-module means that there exists an operation from A$\times X\to X$ and an abelian group (X,+) but this information is not sufficient to prove that a basis exists.

Conversaly, it is given that A-module X is free, ie there exists a basis for elements in X but still I am unable to get any intution why A should be a field.

(b)Let V = Ax be a cyclic free A-module with basis x. Then y = ax $\in V$, a $\in A$ is a basis of V if and only if $a \in A^{\times}$ .

I have done (b).

Kindly help with (a).


Hints:

If $A$ is a field, an $A$-module is more commonly called an $A$-vector space. Can you relate “freeness” to the things you know about vector spaces?

If $A$ is not a field, it will have a proper, non-zero ideal $I$ (as $A$ is non-zero). Look at the $A$-module $A/I$.