I have experienced this behaviour that name is added when package.json has a name that is different from project root directory name.
projectdir/package.json with name="projectdir" => no name in package-lock.json
projectdir/package.json with name="anothername" => name="anothername" in package-lock.json