Let $X$ be a non-compact metric space (though if the answer to the question is positive, then it probably also holds for more general spaces like, e.g., paracompact Hausdorff) and $E \to X$ a vector bundle over it.



> 
> Suppose that over every compact subset $K \subset X$ the restricted bundle $E|\_K$ is trivial. Can we conclude that $E$ is globally trivial?
> 
> 
> 



vector bundle trivial over every compact subset, then it is globally trivial
As Igor Belegradek showed in the comments, one could find an example by finding a CW-complex $X$ and a map $X \to BO(n)$ which is not nullhomotopic, but where the restriction to every finite subcomplex is nullhomotopic. Such a map is called a phantom map. The question "is this map nullhomotopic?" has the same answer whether or not we are asking our maps to preserve the basepoint, and so I will take some steps that are casual about basepoints.


For our example, we're going to take $n = 3$ and $X = \Sigma \mathbb{CP}^\infty$, the suspension of $\mathbb{CP}^\infty$. This is a CW-complex whose finite subcomplexes are $\Sigma \mathbb{CP}^n$.


These spaces are simply connected, so $[\Sigma \mathbb{CP}^n, BO(3)] = [\Sigma \mathbb{CP}^n, BSO(3)]$ for all $n \leq \infty$.


Then $[\Sigma \mathbb{CP}^n,BSO(3)] = [\mathbb{CP}^n, SO(3)]$ for all $n \leq \infty$ by the loop-suspension adjunction. ("A vector bundle on a suspension is determined by a clutching function.")


We can also identify $SO(3)$ with $\mathbb{RP}^3$, which has $S^3$ as a double cover. Again because $\mathbb{CP}^n$ is simply connected, $[\mathbb{CP}^n,SO(3)] = [\mathbb{CP}^n, S^3]$ for all $n \leq \infty$.


One of the famous examples of phantom maps is a map constructed by Brayton Gray: a map $\mathbb{CP}^\infty \to S^3$ which is not nullhomotopic, but where the restriction to $\mathbb{CP}^n$ is nullhomotopic for any $n$. (I believe that this is in his paper "Spaces of the same $n$-type, for all $n$", and that a proof can be given using Milnor's $\lim^1$ sequence.) Pushing this back, we get a vector bundle on $\Sigma \mathbb{CP}^\infty$ whose restriction to any finite subcomplex is trivial.


