You can undo the "eject" operation of a Create React App app by adding the
react-scripts package back and changing a couple of lines on the
package.json file to their defaults. You can lose those
/scripts directories too. The only really ugly thing I found on my test (admittedly on a very simple app which is probably not at all representative of the real world) is that a number of packages were added without an easy way to get rid of. But hey, doesn't that sound like good old
To do this, let's assume you've done this:
yarn run v1.3.2
$ react-scripts eject
? Are you sure you want to eject? This action is permanent. (y/N)y
Now, here's how you recover from it:
$ rm -r scripts/
$ rm -r config/
And inside the
package.json file you'll need to revert the "scripts" to their former state:
+ "start": "react-scripts start",
+ "build": "react-scripts build",
+ "test": "react-scripts test --env=jsdom",
+ "eject": "react-scripts eject"
- "start": "node scripts/start.js",
- "build": "node scripts/build.js",
- "test": "node scripts/test.js --env=jsdom"
I've even added the "eject" command back, for completeness.
In my test, "eject" added a few extra keys to this file: "jest", "babel", and "eslintConfig", which you can now remove as well.
$ yarn start should work again.
I'm a complete React noob, so take the contents of this post with a grain of salt. Here's the versions I'm using: