Search code examples
npmcreate-react-app

Why is ejecting a create-react-app app a one way operation?


Note: this is a one-way operation. Once you eject, you can’t go back! … At this point you’re on your own.

Claims the CRA docs. However, I don't see why this is. If I am using a VCS, what is preventing me from rolling back the changes made by running npm run eject? This would imply there's something outside the project that affects it, which violates some vague notions about principles of modern web dev that I have in my head..


Solution

  • You can revert eject if you revert the changes in VCS.

    eject will just copy configuration files to your working directory so that you have edit them the way you want.

    Keep in mind that once you eject, there could be changes in structure in node_modules as scripts will be looking in different paths. Also, node_modules are generally not tracked in version management systems. So after you revert the eject, you might have to install dependencies with npm install or yarn

    If that doesn't work, try removing node_modules directory and run npm install or yarn again.

    Basically, everything that is tracked in version management systems can be reverted back.