Extending vector bundles on a given open subscheme, reprise
The simplest example is the following. Take $X = A^3$ with coordinates $(x,y,z)$, and let $E = Ker(O_X \oplus O_X \oplus O_X \stackrel{(x,y,z)}\to O_X)$. Let $U$ be the complement of the point $(0,0,0) \in X$. Then $E_{|U}$ is a vector bundle. On the other hand, $E$ is not a vector bundle, but $E^{**} \cong E$, hence $E$ is the reflexive envelope of $i_*i^*E$, and thus there is no vector bundle on $X$ extending $E_{|U}$.
[Edit by Anton: I just spent some time digesting some pieces of the above answer, so figured I'd include the results for future readers similar to me.]
("$E$ is not a vector bundle") The sequence $O_X\xrightarrow{\pmatrix{z\\ y \\ x}}O_X^3\xrightarrow{\pmatrix{y & -z & 0\\ -x & 0 & z\\ 0 &x&-y}}O_X^3\xrightarrow{\pmatrix{x& y& z}}O_X$ is exact, so $E$ is the cokernel of the first map. Since taking fibers commutes with taking cokernels, we compute that $E$ has 2-dimensional fibers away from the origin, and 3-dimensional fiber at the origin.
("$E^{**}\cong E$") Note that $E$ is $S_2$ (i.e. sections defined away from codimension 2 extend uniquely) since it is the kernel of a map from an $S_2$ sheaf to a torsion-free sheaf (the section of $O_X^3$ extends uniquely, and its image is zero away from codimension 2, so must be zero, so the extended section is in $E$). Note also that the dual of any sheaf is $S_2$ (if $\phi\colon F\to O_X$ is defined on an open set $V$ with codimension 2 complement and $s$ is a section, $\phi(s)$ must be the unique extension of $\phi(s|_V)$ as a section of $O_X$), so $E^{**}$ is $S_2$. The canonical map $E\to E^{**}$ is then a map of $S_2$ sheaves which is an isomorphism away from codimension 2, so it must be an isomorphism.
("and thus there is no vector bundle on $X$ extending $E|_U$") If $F$ is an $S_2$ extension of $E|_U$ (i.e. $i^*F=i^*E$), then there is a map $F\to i_*i^*E\to (i_*i^*E)^{**}=E$ which is an isomorphism over $U$, so is an isomorphism by the argument in the previous paragraph. A vector bundle extension would be a different $S_2$ extension.
This is a little perverse, but rather than answering the question, I want to explain what can go wrong when attempting to construct an example. This is the sort of thing one never does normally so I think it's kind of interesting.
If $X$ is a smooth curve, then any vector bundle $E$ on an open set $U$ extends. To see this, we can assume after shrinking $X$, that $E$ is trivial. Then it can be extended to a trivial bundle (the extension is not unique).
If $X$ is smooth surface, then any vector bundle $E$ on an open set $U$ extends. (I think that Olivier Benoist's answer contains a very nice idea, but I don't think the conclusion is OK.) To simplify the argument, assume that $X-U=\{p_1,p_2\ldots \}$ is zero dimensional. We can find finitely sections in a neigbourhood $V$ of $p_i$ which generate $E^*$. This yields an inclusion $E|_V\hookrightarrow \oplus \mathcal{O}_V^n$, and therefore $j_*E|_V \hookrightarrow\mathcal{O}_X^n$, where $j:U\hookrightarrow X$ is the inclusion. It follows easily, that $j_*E$ is coherent. Therefore $F=(j_*E)^{**}$ is a reflexive extension of $E$. However, reflexive sheaves have depth 2. Since by Auslander-Buchsbaum-Serre depth+proj.dim=2 in $\mathcal{O}_{p_i}$, we can conclude that $F$ is in fact locally free.
In view of jvp's answer, we see that 2 does not hold in the analytic category.
One might seek a topological obstruction involving Chern classes as in David Treumann's comment, however: Claim: Any Chern class on $U$ extends to $X$, where $X$ is a smooth partial compactification. Proof: With a bit of fiddling one can see that $c_p(E)$ would lie in $W_{2p}H^{2p}(U,\mathbb{Q})=im H^{2p}(X,\mathbb{Q})$ by Deligne, Theorie de Hodge II, III
In the analytic category there are line-bundles over $X = \mathbb C^2 - \{ 0\}$ which do not extend to $\mathbb C^2$. Since $X$ has the homotopy type of the sphere $S^3$, the exponential sequence $$ 0\to \mathbb Z \to \mathcal O_X \to \mathcal O_X^* \to 1 $$ implies $H^1(X,\mathcal O_X) = H^1(X, \mathcal O_X^*)$. As $H^1(X,\mathcal O_X)$ is infinite dimensional, there are many non-zero elements in $H^1(X,\mathcal O_X^*)$. These define line-bundles which do not extend.