How to save exact npm package versions
Dale L. Jefferson
Posted on May 30, 2019
I've recently started using exact versions in my package.json. This allows me to have more control over my versions and with tools like Renovate this is easier than ever.
What is an exact version?
"react": "^16.0.0" // carat: allow 16.1.0
"react": "~16.0.0" // tilde: allow 16.0.1
"react": "16.0.0" // exact: only 16.0.0
Why
Renovate has great documentation on why you would do this dependency-pinning
How
There are two ways to force npm or yarn to save exact versions in your package.json.
1. Everytime you install a package
// npm
npm install --save --save-exact react
// yarn
yarn add --exact react
2. Set a default in your config
npm config set save-exact=true
This adds save-exact=true
to your .npmrc
💖 💪 🙅 🚩
Dale L. Jefferson
Posted on May 30, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
undefined Setting Up a Node.js Development Environment with MySQL, Sequelize, and TypeScript
November 29, 2024
angular A Practical guide to building cross-platform apps with Angular, Ionic, Capacitor, and Nx
November 29, 2024
astro The Single Quote Curse: When AI Mistook an MDX Front Matter Issue for a YAML Bug
November 29, 2024