In my package.json file i want to update dependencies & devdependencies in my project.
I don't know how to update it
I will post 2 approaches
To update package.json in addition to the local modules, run
npm update --save-dev To update to a new major version all the packages, install the npm-check-updates package globally:
npm install -g npm-check-updates then run it:
ncu -u This will upgrade all the version hints in the package.json file, to dependencies and devDependencies, so npm can install the new major version.
You are now ready to run the update:
npm update note npm update will ignore devDependencies unless the -- dev flag is added.npm update will not upgrade to the latest major version. It makes sense since major releases frequently introduce breaking changes, and it needs to be handled with caution.
-- dev flag; I think you meant the --save-dev flag?--save-dev. Is there any other reason npmwould skip these?--save flag, it does the jobYou can update all dependencies and devDependencies to their respective new major versions by running the following commands:
npm install -g npm-check-updates ncu -u rm -rf node_modules && rm package-lock.json npm i --legacy-peer-deps Please note that npm i --legacy-peer-deps is recommended because there might be some errors (due to issues with resolving the dependency tree) while you install new package versions using the approach above. If you run into any further error with any particular package, just manually choose the right version for that specific error-causing package.
npm updatesimple as that