7

On npm install, I see that in package-lock.json property packages[""].name is sometimes removed and sometimes added. How to prevent this change, since it appears in git changes?

package-lock.json

Miki
  • 85
  • 6
  • did you try to remove the node_modules file and this package.lock.json file? Please do that and then again install "Npm install", that'd be solved. – Zia Ullah Oct 08 '21 at 10:16
  • Yeah. I'm wondering if someone knows the reason. – Miki Oct 08 '21 at 10:39
  • None of the answers are satisfactory yet. At work we've some shared packages, and after some clean install the package-lock.json files have been updated with this `name` despite the fact those shared packages have had the `name` property since the beginning. It's kind of odd. – uzluisf Jun 27 '23 at 15:09

2 Answers2

1

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

AndiDev
  • 1,272
  • 14
  • 26
  • I have the same issue, but my project folder name and the name in the package.json are the same – Liron May 15 '22 at 15:10
0

I had the same problem an found the solution to remove the package name in package.json file. So I remove this line:

"name": "My package name",