In my react application, there is both package.lock.json and yarn.lock.json. I dont know how this happened but I don't want to use both in same application, right?. Whenever I deploy my application to heroku, there was some issues because of this. How can I handle this properly?.
Thank you!
Technology Enthusiast
Vishwa Bhat
See the role of
*.lock.jsonis to lock a particular version of a dependency listed inpackage.jsonand is downloaded innode_modulesfor your application so that next time you want to install dependencies in a new system/environment, your package manager downloads dependencies of same version as in*.lock.jsoninstead of latest(major/minor) version possible listed inpackage.jsonWhenever you use Yarn as your package manager(ie, invoke yarn commands in terminal), it creates
yarn.lock.jsonand with npm (npm commands in terminal), it createspackage.lock.jsonbut if you use both, there is a likely chance that your dependency versions might conflict mainly because you might've used yarn and npm in different point in times. So always use one of the package managers but not both.So to answer you question: If you want to use yarn, delete
package.lock.jsonand rely only onyarn.lock.json. Usually, there wouldn't be major version changes between those lock files otherwise one of the package managers would warn stating that their*.lock.jsonis not matching with dependencies downloaded in node_modules.