Skip to content

Latest commit

 

History

History
89 lines (62 loc) · 1.83 KB

File metadata and controls

89 lines (62 loc) · 1.83 KB

upgrade

To upgrade the dependencies in your package.json to the latest versions, you have several options. Here's a systematic approach:

1. Using npm outdated and npm update

# Check which packages are outdated
npm outdated

# Update packages within the version range in package.json
npm update

# Update to the latest versions (including major versions)
npm update --latest

2. Using npm-check-updates (recommended)

This tool specializes in updating package.json dependencies to the latest versions:

# Install npm-check-updates
npm install -g npm-check-updates

# Check for updates without modifying package.json
ncu

# Update all dependencies in package.json to the latest versions
ncu -u

# Then install the updated packages
npm install

3. Selective updates

If you want more control, you can update specific packages:

# Update a specific package to latest
npm install package-name@latest

# Update multiple specific packages
npm install package1@latest package2@latest

4. Using the upgrade.sh script

You already have an upgrade.sh script that we created earlier. You can run it for an interactive upgrade process:

./upgrade.sh

5. Safe upgrading strategy

For a production project, consider this safer approach:

  1. Create a git branch for the upgrade

    git checkout -b dependency-upgrade
  2. Update dependencies in batches by type

    # Update development dependencies first
    ncu -u -f "/eslint|babel|webpack/"
    npm install
    
    # Update utility libraries
    ncu -u -f "/chalk|minimist|uuid/"
    npm install
    
    # Update React-related packages
    ncu -u -f "/react|jsx/"
    npm install
  3. Run tests after each batch

    npm test
  4. Commit working changes

    git commit -am "Update dependencies: [category]"