Before you flag it as duplicate, I have searched for the similar questions and none of them helped me.
Currently this is what I have tried:
- Delete package-lock.json file.
- Delete node_modules.
- Run
npm update
- Run
npm install
This would always allow me to install the latest (minor) version of the packages in node_modules, and update the package-lock.json file. However, the package.json file does not update.
For example, my moment is package.json is stated as "moment": "^2.27.0". After running above steps, package-lock.json will update to "moment": { "version": "2.29.1", ...} But package.json will still be "moment": "^2.27.0".
What is the correct way to do this? Running npm install moment
manually updates the package.json to become "moment": "^2.29.1" but its quite absurd if I have to run npm install for every single dependency?
Edit Thanks to the selected answer, I realised that I do not actually need to update my package.json, as it shows compatible version, not exact version.