undo 'npm run eject' in react

后端 未结 3 1327
自闭症患者
自闭症患者 2021-02-01 17:55

I was trying to test the performance of my React app(created with create-react-app) with react CDN script and i did \'npm run eject\' to add webpack ex

相关标签:
3条回答
  • 2021-02-01 18:19

    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
    0 讨论(0)
  • 2021-02-01 18:24

    Deletion and then npm install method mentioned is correct. However, if you are using git (or just any version control), just do:

    git checkout -- .
    

    or:

    git stash
    
    0 讨论(0)
  • 2021-02-01 18:28

    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.....

    0 讨论(0)
提交回复
热议问题