undo 'npm run eject' in react

You can undo the "eject" operation of a Create React App app by adding the react-scripts package back. Command yarn or npm based on Your favorite Package manager

What you did:

$ yarn run eject/ npm run eject 
? Are you sure you want to eject? This action is permanent. (Yes/No)Yes

Now Solution for it is to:-

$ rm -r scripts/  //Remove Your scripts folder 
$ rm -r config/   //Remove Your config folder
$ rm -r node_modules//  //Remove Your node_modules folder

And Add react-scripts package back using

$ yarn add react-scripts / npm install react-scripts 

And inside the package.json file you'll need to change 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"      
  }

Now install all dependency using:-

  $ yarn install / npm install 

And You are good to go

$ yarn start / npm start

You made it.....


If you're in now master branch (Which configuration is same as before npm run eject), then try following.

  • Delete node_module
  • npm install
  • npm start