I am not an expert in LaTeX, but I was writing a paper, everything was going fine, until it suddenly crashed giving me the error:
The fontspec package requires either XeTeX or LuaTeX to function.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.Sign up to join this community
fontspec package package requires a compatible compiler or engine, like Xe(La)TeX or Lua(La)TeX. These compilers are better-equipped to handle fonts.
Depending on your compilation protocol (via prompt or command-line, a GUI-like interface or even online), you may have to specify it in the command-line:
xetex <your-tex-file> xelatex <your-tex-file> luatex <your-tex-file> lualatex <your-tex-file>
If you're using some interface like a (La)TeX IDE, then the compiler selection would most likely be somewhere in the interface options. It may even be specified as command-line choice. For example, in TeXnicCenter under Windows, compiler choices can be specified by changing the "Path to the (La)TeX compiler":
Online compilers, like Overleaf, provide similar functionality. You can change the compiler to use a different engine in the project settings. See Changing compiler, where you should select Xe(La)TeX or Lua(La)TeX...