2

I don't know how to go back from React 16 to React 15.

I had the following lines in my package.json file,

  "dependencies": {
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
  }
}

then I launched

npm install --save react@^16.0.0 react-dom@^16.0.0

which installed react 16.1.1. Then I saw a bug and wanted to go back, but, even with the following lines, which specify the exact version of react to use, react 16 continues to be used.

  "dependencies": {
    "react": "15.6.1",
    "react-dom": "15.6.1",
  }
}

How do I go back to React 15?

cdarwin
  • 4,141
  • 9
  • 42
  • 66

3 Answers3

4

After updating dependencies inside package.json you need to run npm install for the changes to take place.

Or if you want to do it all inside of command line you can do it like this:

npm install --save react@15.6.1 react-dom@15.6.1
linasmnew
  • 3,907
  • 2
  • 20
  • 33
1

Firstly update react version in package.json. Then, Delete folder node_modules from the project structure. And at last npm install.

Installation will fail if there is any version mismatch. Please check for all the dependencies & then install those with the compatible version. Update those and run npm install again.

Good Luck !!

Sumant Kataria
  • 43
  • 1
  • 1
  • 8
0

If you are using git and you can roll back your commit, make sure you are in root of project directory then run this to find your changes: git log for instance 0766c053 is the commit you want to revert: git revert --no-commit 0766c053..HEAD rm -rf node_modules npm i This will roll back to the exact package version you were before. If you don't use git you should do like Lina says: npm install --save react@15.6.1 react-dom@15.6.1

Iman Mohamadi
  • 6,552
  • 3
  • 34
  • 33