Skip to content

Latest commit

 

History

History
105 lines (74 loc) · 1.93 KB

How to Safely Update Npm Packages.md

File metadata and controls

105 lines (74 loc) · 1.93 KB

tags: 📥/📽️ aliases:

cssclass: type: video status: 🟩

Title: [[How to Safely Update Npm Packages]]

Metadata

  • Tags:
  • Title: How to Safely Update Npm Packages
  • Type: [[+]]
  • Channel/Host: Coding in Public
  • Reference:
  • Publish Date:
  • Creation Date: $= dv.current().file.ctime
  • Last Modified Date: $= dv.current().file.mtime

Embedded Video

YouTube Video


Steps

0. Setting up node/npm via nvm

# Check what node versions are out there
nvm ls-remote

# Intall the version
nvm install 20.11.0

# Use the version
nvm use 20.11.0

# Set the default node version across terminals
nvm alias default 20.11.0

# Check
node -v
npm --version

Note: npm comes bundled with Node.js, so when you install a specific version of Node.js, it automatically includes a corresponding version of npm.

1. Install NPM Check Updates

# Will install globally
npm install -g npm-check-updates

2. Run NPM Check Updates

# Will list packages that need updating
npx ncu

3. Update Patches

Only updates patches (e.g. 0.0.1 -> 0.0.23)

npx ncu -u -t patch

# Install to make sure everything is still working - will update package-lock.json
npm i

4. Update Minor Versions

Updates minor versions (e.g. 0.3.0 -> 0.5.0)

npx ncu -u -t minor

# Install to make sure everything is still working - will update package-lock.json
npm i

5. Update Major Versions

These should be updated with caution as there may be breaking changes. Read release note docs to check how the changes will affect your project.

Updates major versions (e.g. 1.0.0 -> 2.0.0)

# Run on individual packages by using the `-f` or `-filter` flags
npx ncu -u -f axios

# Install to make sure everything is still working - will update package-lock.json
npm i

🔗 Links to this page: [[Javascript]] [[npm]]