Consider this script:
\documentclass{article}
%\usepackage[latvian]{babel}
\usepackage{listings}
\begin{document}
\end{document}
I get an error
(/usr/local/texlive/2018/texmf-dist/tex/latex/listings/listings.cfg))
(./latvianpres.aux)
! LaTeX Error: No counter 'chapter' defined.
if I uncomment the line
%\usepackage[latvian]{babel}
What is the problem and how to solve it?