Let $M$ and $N$ be $R$ modules ($R$ commutative with identity). Is it true that if for every prime ideal $P$, $M_P \cong N_P$ (as $R_P$ modules) then $M \cong N$ ? Clearly the question is true if $M$ or $N$ is zero. But what about the nonzero case !?

Here is an explicit counterexample: Let $R^3$ be euclidean 3space and $S^2$ the 2sphere, embedded in $R^3$ as usual. Let $A$ be the ring of all realvalued continuous functions on $S^2$. Let $T$ be the $A$module of all $R^3$valued continuous functions on $S^2$ (so that $T\approx A^3$ is a free $A$module). Let $M\subset T$ consist of all those functions $f$ such that $f(x).x=0$ for all $x$ (where "dot" denotes the usual inner product in $R^3$). Let $M'\subset T$ be the submodule generated by the identity function. Observation 1: $M\oplus M'=T$. Thus, for any prime $P\subset A$, we have $M_P\oplus M'_P\approx T_P$. But over a local ring, any direct summand of a free module is free. Therefore $M_P$ is free. Observation 2: $M$ can't be free. If it were, it would have a basis consisting of two triples $(f_1,f_2,f_3)$ and $(g_1,g_2,g_3)$ (the entries $f_i$ and $g_i$ being realvalued functions). This basis, together with the basis consisting of the single element $(x,y,z)$ for $M'$, would form a basis for $T$. It would follow that the matrix $$\pmatrix{f_1&f_2&f_3\cr g_1&g_2&g_3\cr x&y&z\cr}$$ has unit determinant; in particular the determinant is a function on $S^2$ with no zeros. But it is a fact from topology that if $f(x).x=0$ for all $x$, then there is some $x$ such that $f(x)=(f_1(x),f_2(x),f_3(x))=(0,0,0)$. Thus the determinant of the displayed matrix has a zero at $x$. This contradiction shows that $M$ is not free. Now let $N$ be a free $A$module of rank 2. Observation 1 shows that $M_P\approx N_P$ for all primes $P$; Observation 2 shows that $M$ is not isomorphic to $N$. 


No in general, per Fernando's comment. Yes if you have a single map $M\rightarrow N$ that localizes to isomorphisms at every prime $P$ (compute the kernel and cokernel and use your observation about zeromodules). 

