How do I change the default prefix character (^
) that npm
inserts in package.json
when I run npm install --save package
?
Caret (^) notation: It is used for automatically updating the minor updates along with patch updates. Example: The ^1.2. 4 will update all the future Minor and patch updates, for example, ^1.2. 4 will automatically change the dependency to 1. x.x if any update occurs.
npm uses the tilde (~) and caret (^) to designate which patch and minor versions to use respectively. If you see ^1.0. 2 it means to install version 1.0. 2 or the latest minor or patch version such as 1.1.
Peer Dependencies: In package. json file, there is an object called as peerDependencies and it consists of all the packages that are exactly required in the project or to the person who is downloading and the version numbers should also be the same. That is the reason they were named as peerDependencies.
npm config set save-prefix='~'
sets your default back to tilde
npm config set save-prefix=''
will remove the auto-prefixing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With