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 /config and /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 npm anyway?

To do this, let's assume you've done this:

$ yarn eject
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:

$ yarn add react-scripts
$ rm -r scripts/
$ rm -r config/

And inside the package.json file you'll need to revert the "scripts" to their former state:

   "scripts": {
+    "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.

Final thoughts

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:

yarn 1.3.2
create-react-app 1.5.1
react 16.2.0
react-scripts 1.1.0
Latest
Mastodon Mastodon