NPM Caret and Tilde Version Rules | Generated by AI

Home 2026.02

In package.json, the ~ and ^ characters control how npm updates your dependencies:

^ (caret) - minor and patch updates

~ (tilde) - patch updates only

Practical example:

{
  "dependencies": {
    "react": "^18.2.0",     // can update to 18.x.x
    "lodash": "~4.17.21",   // can only update to 4.17.x
    "express": "4.18.2"     // exact version, no updates
  }
}

Most projects use ^ because it balances getting bug fixes and new features while avoiding breaking changes. If you need maximum stability (like in production apps), you might use ~ or exact versions, and commit your package-lock.json to ensure everyone gets identical dependencies.


Back Donate