Skip to content
Fix Code Error

What’s the difference between tilde(~) and caret(^) in package.json?

March 13, 2021 by Code Error
Posted By: Anonymous

After I upgraded to the latest stable node and npm, I tried npm install moment --save. It saves the entry in the package.json with the caret ^ prefix. Previously, it was a tilde ~ prefix.

  1. Why are these changes made in npm?
  2. What is the difference between tilde ~ and caret ^?
  3. What are the advantages over others?

Solution

See the NPM docs and semver docs:

  • ~version “Approximately equivalent to version”, will update you to all future patch versions, without incrementing the minor version. ~1.2.3 will use releases from 1.2.3 to <1.3.0.

  • ^version “Compatible with version”, will update you to all future minor/patch versions, without incrementing the major version. ^2.3.4 will use releases from 2.3.4 to <3.0.0.

See Comments below for exceptions, in particular for pre-one versions, such as ^0.2.3

Answered By: Anonymous

Related Articles

  • npm install error in vue
  • How to represent arrays within ember-data models?
  • Use of PUT vs PATCH methods in REST API real life scenarios
  • using d3.js with aurelia framework
  • Rails wrong number of arguments error when…
  • How to properly update the library parts
  • Aurelia CLI & TypeScript & MomentJS
  • What does do?
  • Why is Future[Set[Unit]] not accepted as Future[Unit]?
  • Ukkonen's suffix tree algorithm in plain English
  • How do I install Java on Mac OSX allowing version switching?
  • error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or…
  • Is this request generated by EF Core buggy or is it my code?
  • 'block in draw' rails 6 routes
  • How to import Moment-Timezone with Aurelia/Typescript
  • Aurelia bundling issue with virtual directory
  • how to turn a recursive algorithms into an iterative one
  • NodeJS - Error installing with NPM
  • How to print binary tree diagram?
  • How to create and publish a Vuejs component on NPM
  • Can't correctly import external JS into Aurelia…
  • Deprecation warning in Moment.js - Not in a…
  • Combining Ember Table with Ember Data
  • Codeigniter rest issue with backbone
  • Vue: How do you add E2E tests after not including…
  • How to print an AST from a parser generator to graphviz?
  • Running Python on Windows for Node.js dependencies
  • Problems Installing CRA & NextJS from NPM…
  • How to update Python?
  • Aurelia UX showcase app fails to load
  • Homebrew install specific version of formula?
  • How do I tell Maven to use the latest version of a…
  • sidebar background is not going full to the bottom
  • Vue modules, moment-timezone - How to load…
  • configure: error: C compiler cannot create executables
  • Runing vue/cli app under docker simple index.html is opened
  • What's the difference between Instant and LocalDateTime?
  • NPM restore attempting to retrieve non-existent node-sass
  • How to specify typecllass function type to operate…
  • module.exports cannot find module
  • How should I deal with "package '✘✘✘' is not…
  • How do I completely uninstall Node.js, and reinstall…
  • Node.js Error: Cannot find module express
  • How do I deal with installing peer dependencies in…
  • How do I resolve `The following packages have unmet…
  • What's the difference between dependencies,…
  • Android splash screen image sizes to fit all devices
  • data.table vs dplyr: can one do something well the…
  • Unexpected end of JSON input while parsing
  • How can I find the product GUID of an installed MSI setup?
  • store struct of info in single linked list
  • SystemJS (Aurelia with jspm) fails to load…
  • Why does C++ code for testing the Collatz conjecture…
  • Ember-cli-dependency-checker - Invalid Version: *
  • Reference — What does this symbol mean in PHP?
  • npm install -g less does not work: EACCES: permission denied
  • Is it possible to use the frontend-maven-plugin for…
  • Named tuple and default values for optional keyword…
  • How to recover stashed uncommitted changes
  • Webpack build error
  • How do SO_REUSEADDR and SO_REUSEPORT differ?
  • Difference between Grunt, NPM and Bower (…
  • Why does the function named "traverse" not work on my code?
  • Eclipse will not start and I haven't changed anything
  • What are differences between AssemblyVersion,…
  • Understanding esModuleInterop in tsconfig file
  • Start redis-server with config file
  • next/node app deployment errors with heroku
  • Invalid Version: Ember-Cli-Babel
  • Aurelia npm install: tons of "gyp ERR"
  • Memcached vs. Redis?
  • npm install vs. update - what's the difference?
  • How do you create a custom neon animation in Dart
  • Unable to read repository at…
  • Node update a specific package
  • moment: Array.prototype.some called on null or undefined
  • Error: Node Sass version 5.0.0 is incompatible with ^4.0.0
  • How to simplify sequential logic design by…
  • In plain English, what does "git reset" do?
  • Why do I get different version of a dependency in…
  • npm run dev command does not work on vuejs'…
  • Error: Can't set headers after they are sent to the client
  • Can't Install Ember-CLI without sudo
  • What does this symbol mean in JavaScript?
  • Getting Bad Request 400 when sending data to django…
  • How to use moment.js library in angular 2 typescript app?
  • how to integrate selenium driver for chrome and…
  • How to compile or convert sass / scss to css with…
  • What is Ember RunLoop and how does it work?
  • What are the new features in C++17?
  • error 'moment' is not defined no-undef in ember.js
  • Polymer CLI build runs out of memory
  • Npm run serve Error
  • How to use Servlets and Ajax?
  • C# parse FHIR bundle - read resources
  • Loop with nested polymer elements?
  • Checkout another branch when there are uncommitted…
  • load list from file in c
  • Encoding JSON to URL params for Backbone.Model.save…
  • Google polymer starter kit WARN when npm install

Disclaimer: This content is shared under creative common license cc-by-sa 3.0. It is generated from StackExchange Website Network.

Post navigation

Previous Post:

Android Studio doesn’t see device

Next Post:

Remove border from IFrame

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

.net ajax android angular arrays aurelia backbone.js bash c++ css dataframe ember-data ember.js excel git html ios java javascript jquery json laravel linux list mysql next.js node.js pandas php polymer polymer-1.0 python python-3.x r reactjs regex sql sql-server string svelte typescript vue-component vue.js vuejs2 vuetify.js

  • you shouldn’t need to use z-index
  • No column in target database, but getting “The schema update is terminating because data loss might occur”
  • Angular – expected call-signature: ‘changePassword’ to have a typedeftslint(typedef)
  • trying to implement NativeAdFactory imports deprecated method by default in flutter java project
  • What should I use to get an attribute out of my foreign table in Laravel?
© 2022 Fix Code Error