DEV Community

Discussion on: But what the hell is package-lock.json?

Collapse
 
taimoorkhan profile image
Taimoor khan

Hi Saurabh Thanks for the super easy explanation of Package-lock.json.
Right now I am learning React and every time I have to add new dependency in my app I use npm install somePackageName and the get the error

npm ERR! Cannot read property 'match' of undefined

so every time I delete package-lock.json file and again run the same command and this time with success result. This is what brought me here

Collapse
 
saurabhdaware profile image
Saurabh Daware 🌻

That's a weird error. Maybe you should try having --save-dev or --save flag on npm install. Not sure about what the default npm install behavior is but normall --save or --save-dev will add it to package.json dependency object and it will be installed locally.

Collapse
 
taimoorkhan profile image
Taimoor khan

tried that too but that didn't solved the problem...! I had to delete package-lock.json and then execute the command again...