node.jsnpmnpm-update

How do I npm update dependency versions in the package-lock.json?


As in the title, but:

How to best solve this? If I'm installing from package.json anyway, is it a good practice to just delete the package-lock.json? Should I rather keep it updated? What to do if I want to use the lock instead?

I have never done anything like this before, so I'm not even sure that if I just rewrote a version string in the json it would work or break the npm install.

Is there a safe/professional way to change to package-lock.json, and keep it updated via npm?


Solution

  • If you want update version in package-lock.json,you can do it by updating the package using

    npm update <package_name>
    

    Read more about '^' and '~' in your package.json >> Reference

    As the package-lock specifies a version, location and integrity hash for every module and each of its dependencies, the install it creates will be the same, every single time for each user in shared project.

    Everything You Wanted To Know About package-lock.json

    Hope this will help you clear your thoughts.