Proper mechanism to downgrade react-native

My situation is this :

I had a working copy of a react-native project that was working well. Had it commited to my git repository.

I decided to upgrade react-native to 0.26.3 and then 0.28 and finally ended up in a big dependency mess with collisions. So decided to go back to previous working version. Reverted the changes. Removed node_modules folder from my working directory.

But now npm install just won't work.

My working dependencies in package.json

  "dependencies": {
    "immutable": "^3.8.1",
    "key-mirror": "^1.0.1",
    "react": "^15.0.2",
    "react-native": "^0.26.0",
    "react-native-router-flux": "^3.26.1",
    "react-redux": "^4.4.5",
    "redux": "^3.5.2",
    "redux-thunk": "^2.1.0",
    "strformat": "0.0.7"
  },
  "devDependencies": {
    "babel-core": "^6.10.4",
    "babel-jest": "^12.1.0",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-react-native": "^1.9.0",
    "babel-register": "^6.9.0",
    "chai": "^3.5.0",
    "fetch-mock": "^4.5.4",
    "jest-cli": "^12.1.1",
    "mocha": "^2.5.3",
    "mockery": "^1.7.0",
    "nock": "^8.0.0",
    "redux-mock-store": "^1.1.1",
    "sinon": "^1.17.4",
    "sinon-chai": "^2.8.0",
    "sinon-stub-promise": "^2.0.0"
  }

Now I get

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer [email protected] wants [email protected]
npm ERR! peerinvalid Peer [email protected] wants [email protected]^0.14.0 || ^15.0.0-0

This just not makes sense to me, as my react dependency is 15.0.2 and react-native 0.26.0 as you can see in package.json.

Note that this is from a previous commit that was working (the whole lot). I also did a npm ls. Weirdly wrong dependencies are shown in the tree like wrong versions of react-native, react-native-router-flux, react.

link to ls output

Answers:

Answer

Please update your react dependency in package.json to explicitly be 15.0.2, not ^15.0.2 since the latter resolves to 15.1.0 which causes this issue. It is recommended to leave it that way until you upgrade for the next time and get this error once again (to avoid react changing its version in the meantime and react-native not being ready for it).

Also, with npm3 EPEERINVALID is no longer an error, but warning.

Answer

For existing projects if you want to install/downgrade to lower version

npm install [email protected]  ex: npm install [email protected]

This will install the version specified.

Check the installed version react-native -version

Answer

Update 2020

Just run

npm install [email protected]

Replace 0.43.8 with version you need.

Answer

Try npm prune and then npm i again.

The command npm prune will basically remove all unwanted packages, and npm i will make sure all missing packages are installed.

Answer

Downgrading React Native requires manual steps. I recommend using https://github.com/react-native-community/rn-diff-purge/compare/. here are my steps

  1. Set your current version as base and select the previous minor release of react-native (You should downgrade one version at a time, it's not very easy to downgrade from 0.61.x to 0.59.x or lower using this method)
  2. Revert all the changes made to files as displayed in the compare view
  3. Delete node_modules folder, clear watchman, reset metro cache, Clear ios cached files and Android cached file.
  4. yarn or npm install
  5. Test that both iOS and Android version are working
  6. (if needed) Repeat the steps to downgrade to another lower version

Important: If you're downgrading multiple versions then you should downgrade one version at a time. For example, downgrading from 0.61.x to 0.58.x, should towngrade to version 0.60.x first, test that it works in iOS and Android then move on and downgrade to version 0.59.x

Answer

If you're using react-native you can modify your package.json file with the versions that you need and then delete all your node modules rm -rf node_modules and then reinstall npm install

Answer

If you change the version in Package.json and reinstall npm packages it will make build errors. Please refer and downgrade/upgrade to a specific version.

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.