There are many methods available, e.g. the extended Euclidean algorithm, $ $ or a special case of Euclid's algorithm that computes inverses modulo primes that I call Gauss's algorithm. $ $
The calculations are usually simpler using modular fraction arithmetic e.g. see here, and here and here for circa $20$ motley worked examples via a handful of methods (and see the sidebar "Linked" questions lists there for many more).
Update $ $ March $16, 2020\!:\,$ for completeness we apply some of the linked methods below.
$\!\!\bmod 31\!:\,\ \dfrac{1}{7}\equiv \dfrac{4}{28}\equiv\dfrac{-27}{-3}\equiv 9\ $ by Gauss's algorithm.
$\!\!\bmod 31\!:\,\ \dfrac{1}{7}\equiv \dfrac{1}{-6}\,\dfrac{1}{4}\equiv \dfrac{-30}{-6}\,\dfrac{32}{4}\equiv 5\cdot 8\equiv 9$
As here: $ $ the freedom to choose $\rm\color{#c00}{even}$ residue reps $\!\bmod\!$ odds makes division by 2 easy:
$\!\!\bmod 31\!:\,\ \dfrac{1}{7}\equiv\dfrac{\color{#c00}{32}}{\color{#c00}{-24}}\equiv\dfrac{4}{-3}\equiv\dfrac{-27}{-3}\equiv 9$
By the fractional extended Euclidean algorithm, or associated equational form
$ \begin{align} \bmod 31\!:\ \ \dfrac{0}{31}\overset{\large\frown}\equiv\color{#c00}{\dfrac{1}7}\ \, &\!\!\!\overset{\large\frown}\equiv\color{#0a0}{\dfrac{-4}3}\overset{\large\frown}\equiv\color{#90f}{\dfrac{9}1}\\[.7em]
\text{said equationally}\ \ \ \
[\![1]\!]\ \ \ \ 31\, x&\,\equiv \ 0\ \\
[\![2]\!] \ \ \ \ \ \ \color{#c00}{7\,x}&\ \color{#c00}{ \equiv\ 1}\!\!\!\\
[\![1]\!]-4\,[\![2]\!] \rightarrow [\![3]\!]\ \ \ \ \ \ \color{#0a0}{3\,x} &\ \color{#0a0}{\equiv\ {-}4}\ \\
[\![2]\!] - 2\,[\![3]\!] \rightarrow [\![4]\!]\, \ \ \ \ \ \ \ \ \color{#90f}{x}&\ \color{#90f}{ \equiv\ 9}
\end{align}$
Below we explain the basic idea behind the method of Inverse Reciprocity.
$\!\!\bmod 31\!:\,\ n \equiv \dfrac{1}7\equiv \dfrac{1+31\color{#c00}k}7.\ $ For an exact quotient we seek $\,k\,$ with $\,7\mid 1\!+\!31k,\,$ i.e.
$\!\!\bmod 7\!:\,\ \begin{align}0&\equiv 1\!+\!31k\\ &\equiv 1 + 3k\end{align}\!$ $\iff\! \begin{align}3k&\equiv-1\\ &\equiv\,\ 6\end{align}\!$ $\iff \color{#c00}{k\equiv 2},\ $ so $\ n \equiv \dfrac{1\!+\!31(\color{#c00}2)}7\equiv 9\pmod{\!31}$
Or $\rm\ (a,m)\!=\!1 \overset{\rm Euler\ \phi}\Longrightarrow\ a^{-1} \equiv a^{\phi(m)-1}\!\pmod{\! m},\,$ quickly computable by repeated squaring. It suffices to find any (small) period $\rm\,e,\,$ of $\rm\,a,\,$ i.e. $\rm\,e\,$ such that $\rm\,a^{\large e}\equiv 1\,$ (e.g. by Euler's totient or Fermat's little theorem or Carmichael's lambda theorem), since this implies $\rm\,a^{-1}\equiv a^{e-1}$.
Remark $ $ The latter yields a simple closed form for CRT (Chinese Remainder Theorem)
$\quad$ if $\rm\,\ (m,n)\!=\!1\,\ $ then $\rm\quad \begin{eqnarray}\rm x\!&\equiv&\rm a\ \ (mod\ m)\\ \rm x\!&\equiv&\rm b\ \ (mod\ n)\end{eqnarray} \iff\ x\equiv a\,n^{\phi(m)}\!+b\,m^{\phi(n)}\ \ (mod\ mn)$
More generally see the Peirce decomposition.