Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update package.json with versions already installed in package-lock.json? #1392

Closed
Saibamen opened this issue Apr 3, 2024 · 2 comments
Labels

Comments

@Saibamen
Copy link

Saibamen commented Apr 3, 2024

I want to have clear view of already installed package versions in package.json.

I always regenerate package-lock.json file by deleting it and npm install to refresh this file, but I also want to update package.json with latest installed version for specified range.

How to do this?

@raineorshine
Copy link
Owner

raineorshine commented Apr 3, 2024

If your dependencies are specified as a range, such as ^1.2.0, you generally don't need to update the version in your package.json. Just run npm install or npm update.

If for some reason you want to bump the lower bound of the range (e.g. update ^1.2.0 to ^1.4.0 in your package.json, even though 1.4.0 is already included in the range ^1.2.0), then try ncu --target semver.

semver │ Upgrade to the highest version within the semver range specified in your package.json.

@Saibamen
Copy link
Author

Saibamen commented Apr 3, 2024

Thank you. ncu --target semver -u is doing this job very well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants