In the linked piece of code the nonce is prepended to the cipher text. It is therefore recoverable. Losing the nonce means losing data.
In the comments I saw a dangerous idea: Not generating the nonce in a cryptographically secure way. That's not a good idea because you risk colliding nonces that way. It needlessly weakens security.