Plotting a curve using Lualatex within Standalone environment

I am trying to plot a curve as shown below:

%&lualatex
% !TeX program = lualatex
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}
\end{axis}
\end{tikzpicture}
\end{document}


The problem is that the solution works pretty well in pdflatex, however, when I try to compile this MWE (given in the answer) with lualatex, I get a series of errors like:

> ! Undefined control sequence. \sa@placebox ->\newpage \global
> \pdfpagewidth
>                                               =\wd \sa@box \global \pdfpageh... l.13 \end{document}
>                   The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g.,
> \hobx'), type I' and the correct spelling (e.g., I\hbox').
> Otherwise just continue, and I'll forget about whatever was undefined.
>
> ! You can't use a prefix with the character ='. <to be read again>
> = l.13 \end{document}
>                   I'll pretend you didn't say \long or \outer or \global or \protected.
>
> ! Missing number, treated as zero. <to be read again>  \global  l.13
> \end{document}
>                   A number should have been here; I inserted 0'. (If you can't figure out why I needed to see a number, look up weird
> error' in the index to The TeXbook.)
>
> ! Illegal unit of measure (pt inserted). <to be read again>  \global
> l.13 \end{document}
>                   Dimensions can be in units of em, ex, in, pt, pc, cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one! I'll assume
> that you meant to say pt, for printer's points. To recover gracefully
> from this error, it's best to delete the erroneous units; e.g., type
> 2' to delete two letters. (See Chapter 27 of The TeXbook.)
>
> ! Undefined control sequence. \sa@placebox ...wd \sa@box \global
> \pdfpageheight
>                                                   =\ht \sa@box \global \pape... l.13 \end{document}
>                   The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g.,
> \hobx'), type I' and the correct spelling (e.g., I\hbox').
> Otherwise just continue, and I'll forget about whatever was undefined.
>
> ! You can't use a prefix with the character ='. <to be read again>
> = l.13 \end{document}
>                   I'll pretend you didn't say \long or \outer or \global or \protected.
>
> ! Missing number, treated as zero. <to be read again>  \global  l.13
> \end{document}
>                   A number should have been here; I inserted 0'. (If you can't figure out why I needed to see a number, look up weird
> error' in the index to The TeXbook.)
>
> ! Illegal unit of measure (pt inserted). <to be read again>  \global
> l.13 \end{document}
>                   Dimensions can be in units of em, ex, in, pt, pc, cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one! I'll assume
> that you meant to say pt, for printer's points. To recover gracefully
> from this error, it's best to delete the erroneous units; e.g., type
> 2' to delete two letters. (See Chapter 27 of The TeXbook.)
>
>
> Overfull \hbox (30.56pt too wide) in paragraph at lines 13--13
> []\TU/lmr/m/n/10 ==[]   []


Could anyone tell me where it is going wrong?

Disclaimer: I am using the MikTex-2.9.6300 and standalone was packaged on 21-Jul-2015.

• Works for me with TexLive 2018. Doesn't work with TexLive 2016. After adding \RequirePackage{luatex85} at the very beginning (before \documentclass it became working for 2016 as well. Hopefully, someone can explain that. – Sergei Golovan Dec 6 '18 at 8:15
• @SergeiGolovan Thanks for the information, I am using MikTex (probably the not-so-old version). I will update my tag accordingly. – Raaja Dec 6 '18 at 8:27
• "not-so-old" is probably not enough. standalone was updated only a few month ago if I remember correctly. – Ulrike Fischer Dec 6 '18 at 8:37
• relevant is not the version of miktex but of the standalone class. But beside this: MikTex-2.9.6300 is rather old. – Ulrike Fischer Dec 6 '18 at 8:45
• I think my edit interfered. But do you really need a confirmation that a package from 2015 could be a bit old? – Ulrike Fischer Dec 6 '18 at 8:48