简体   繁体   中英

How to update dependencies and dev dependencies in package.json file?

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

  1. To update package.json in addition to the local modules, run

    npm update --save-dev
  2. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM