Cannot uninstall webpack from react-script

54,030

Solution 1

Create a .env file in the root directory of the project and add this line SKIP_PREFLIGHT_CHECK=true inside the file.

then try to run yarn start.

Solution 2

To solve this issue I had to uninstall webpack and webpack-dev-server from the node-modules folder and then install them again but with different versions.

  1. Open cmd on the node-modules folder outside of your project folder

  2. Uninstall webpack and webpack-dev-server:

    npm uninstall webpack
    npm uninstall webpack-dev-server
    
  3. Delete the node-modules folder and the package-lock.json file from your project's folder.

  4. Open the node-modules again

    npm install [email protected]
    npm install [email protected]
    
  5. Use this command on your project folder

    npm install
    

It did the trick for me, hope it helps you too.

Solution 3

One solution I had was to go to my "Home" folder and delete the node_modules folder and package-lock.json file.

Worked afterwards.

Solution 4

Since it looks like the project uses Create React App, Webpack is probably already a dependency in the package.json. So the easy way to install it is to just go to the project directory and type npm install (or yarn install) in the terminal.

If using the Webpack CLI causes errors, it's probably because there's a different version installed globally.

To uninstall it globally, type npm -g uninstall webpack.

Solution 5

I had similar problem today. I resolved with the following steps:

  1. Execute npm ls webpack --> to find out that I have installed Webpack outside my folder ("like yours ... /home/hanna/node_modules/webpack).
  2. Then cd into that location (/home/hanna/node_modules/) and execute npm install [email protected]. That way I have the same version of Webpack like in my project folder.

After that, when I run npm start, it works fine.

Share:
54,030

Related videos on Youtube

Hanna Kogut
Author by

Hanna Kogut

Updated on October 10, 2021

Comments

  • Hanna Kogut
    Hanna Kogut over 2 years

    I was trying to make a todo-app in react, which is new to me. But after once installed webpack, npm start doesnt working. It gives me:

    [email protected] start /home/hanna/Desktop/projects/my-todo-react react-scripts start

    There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally.

    The react-scripts package provided by Create React App requires a dependency:

    "webpack": "4.19.1"

    Don't try to install it manually: your package manager does it automatically. However, a different version of webpack was detected higher up in the tree:

    /home/hanna/node_modules/webpack (version: 4.20.2)

    Manually installing incompatible versions is known to cause hard-to-debug issues.

    If prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will permanently disable this message but you might encounter other issues.

    To fix the dependency tree, try following the steps below in the exact order:

    1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
    2. Delete node_modules in your project folder.
    3. Remove "webpack" from dependencies and/or devDependencies in the package.json file in your project folder.
    4. Run npm install or yarn, depending on the package manager you use.

    In most cases, this should be enough to fix the problem. If this has not helped, there are a few other things you can try:

    1. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead. This may help because npm has known issues with package hoisting which may get resolved in future versions.

    2. Check if /home/hanna/node_modules/webpack is outside your project directory. For example, you might have accidentally installed something in your home folder.

    3. Try running npm ls webpack in your project folder. This will tell you which other package (apart from the expected react-scripts) installed webpack.

    If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That would permanently disable this preflight check in case you want to proceed anyway.

    P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

    npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: react-scripts start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in: npm ERR! /home/hanna/.npm/_logs/2018-10-02T10_39_06_361Z-debug.log

    • Atav32
      Atav32 over 5 years
      How did you install Webpack? Since it looks like the project uses Create React App, Webpack is probably already a dependency in package.json. So the easy way to install it is to just go to the project directory and type npm install (or yarn install) in the terminal. If you installed it globally, you can uninstall it globally with npm -g uninstall webpack.
    • Hanna Kogut
      Hanna Kogut over 5 years
      Yes. Webpack was already in package.json. But in terminal react requires older version of webpack. So I was searching a very long time. And after that I understood that webpack is installed globally. And I uninstalled it and in project folder installed that version that react requires. Thank you very much for answer
    • Atav32
      Atav32 over 5 years
      Great! Glad to hear it worked. I summarized the answer for other readers below.
    • Henke
      Henke about 2 years
  • Hanna Kogut
    Hanna Kogut over 5 years
    I made it in similar way. I uninstalled webpack globally and installed 4.19 version locally in my project folder. Thanks for your answer.
  • Aras
    Aras over 5 years
    I remove my node_modules folder in "Home" and npm start work for me.
  • MdaG
    MdaG about 5 years
    This is the only solution that worked for me all other steps steps yielded nothing.
  • Emil
    Emil about 4 years
    what is the webpack-dev-server for and why you installed different version than webpack?
  • Washington Braga
    Washington Braga over 3 years
    Good job! That was exactly my problem
  • Chandler Bing
    Chandler Bing over 2 years
    Well done bro, very simple solution, worked for me:)