Nano has a flag for line numbers, nano -l, but typing it every time is the kind of small thing that gets old. The same option can live in a config file.
nano -l file.txt
The -l flag is also written --linenumbers and shows line numbers in front of the text. To make it the default, add one line to ~/.nanorc, creating the file if it doesn’t exist:
set linenumbers
A system-wide file, /etc/nanorc, ships with the same line commented out as #set linenumbers, which makes it easy to find the option name. Your own file overrides the system one. Nano also reads ~/.config/nano/nanorc or $XDG_CONFIG_HOME/nano/nanorc, whichever it finds.
While you’re in the file, a few more options in the same list are worth a look. set autoindent keeps the indentation of the previous line, set tabsize 4 changes the tab width, and set tabstospaces types spaces when you press Tab. All three appear in the stock /etc/nanorc as comments.
One caveat: a typo in the file makes nano print an error at startup and ask for a keypress. Check the option names against the sample file. If you only need numbers once, the keybinding in the editor, Alt-n, toggles them on the fly.
Further reading: nanorc manual