Search code examples
reactjsnpmyarnpkgpackage.jsonframer-motion

Installing a specific version of a package with yarn doesn't work


I use framer-motion in a React App. The latest version - 4.1.13 - breaks my ui. I need to downgrade to the previous version - 4.1.2 - (yes, the versioning seems weird, but 4.1.2 is actually prior to 4.1.13, see https://www.npmjs.com/package/framer-motion).

I run the command yarn upgrade framer-motion@^4.1.2. In package.json, the package becomes 4.1.2, but in yarn.lock, the package's version is still 4.1.13:

framer-motion@^4.1.2:
  version "4.1.13"
  resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-4.1.13.tgz#0a7f096113a0f80f11116c1a73da9b81523324cd"
  integrity sha512-E72PyzHXsie1IGcEFMGM3OJsVbtmpS8vcnDjh6tdeCaP7stoioZpmKZcx7c87giymAyuSSWvsGGdVnDGRzRX6g==
  dependencies:
    framesync "5.3.0"
    hey-listen "^1.0.8"
    popmotion "9.3.5"
    style-value-types "4.1.4"
    tslib "^2.1.0"
  optionalDependencies:
    "@emotion/is-prop-valid" "^0.8.2"

I have of course did a rm -rf node_modules && yarn. It doesn't change anything.


Solution

  • The command you ran: yarn upgrade framer-motion@^4.1.2 allows any version in the below range:

    >=4.1.2 <5.0.0
    

    4.1.13 falls in this range so yarn is probably picking up latest. Run yarn upgrade framer-motion@4.1.2 to install the specific version.


    If it doesn't work, as a last resort try adding a:

    "resolutions":
       "framer-motion": "4.1.2"
    }