Non-stoichiometry-induced metal-to-insulator transition in nickelate thin films grown by pulsed laser deposition