Hanna Kogut
Hanna Kogut

Reputation: 430

Cannot uninstall webpack from react-script

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

Upvotes: 27

Views: 75977

Answers (20)

Aastha Singh
Aastha Singh

Reputation: 21

After a lot of trials, I found that the easiest solution is to install the required version of webpack in /home/hanna.

That is,

  1. cd to /home/hanna
  2. run npm i [email protected]

Then, the error will go away. Hope it helps.

Upvotes: 1

lahiru chalana
lahiru chalana

Reputation: 31

I also faced this issue. I had to install [email protected] in the node_modules but after I installed [email protected] there was an error displayed in the CMD:

`-- UNMET PEER DEPENDENCY [email protected]

npm ERR! peer dep missing: webpack@^5.1.0, required by [email protected]

So installing webpack for node_modules didn't work. Then I used .env file to solve this.

First I typed npm add --dev dotenv in the project terminal. Then I created the .env file and typed this code:

SKIP_PREFLIGHT_CHECK=true 

Upvotes: 0

yash sanghavi
yash sanghavi

Reputation: 430

  • Step 1: Create an .env file in the root directory
  • Step 2: add this line into your .env file: SKIP_PREFLIGHT_CHECK=true
  • Step 3:Again npm start

Upvotes: 1

Naazyyy
Naazyyy

Reputation: 1

If you have multiple node_modules folders with different versions of dependencies one may conflict with the other - do the following:

  1. Follow steps 1-4 that are initially provided in project directory and commit updated changes locally~

i. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.

ii. Delete node_modules in your project folder.

iii. Remove webpack from dependencies and/or devDependencies in the package.json file in your project folder.

iv. Run npm install or yarn, depending on the package manager you use.

  1. Find the location of the node_modules folder that is not in your project folder ~ this line - (/home/hanna/node_modules/webpack)

  2. Delete it

  3. npm start

should work :)!

Upvotes: 0

JAnn Ďurčák
JAnn Ďurčák

Reputation: 23

  • npx create-react-app nameOfYourApp
  • find where is your nameOfYourApp and replace src folder with one from previous project
  • use new nameOfYourApp

Upvotes: 0

Thompson Oghenefoke
Thompson Oghenefoke

Reputation: 11

I think if you have a webpack package installed globally it might cause such error. Removing it globally might solve the problem. That's what I did here and it works.

npm uninstall webpack
npm uninstall webpack-dev-server

Delete the node_modules folder and the package-lock.json file from your root directory

##thompsonmax## 

Then you can now run your command to your app,

create-react-app react-app

Upvotes: 1

Praneeth Vithanage
Praneeth Vithanage

Reputation: 211

do this

first code in terminal this -->

 yarn add --dev dotenv

create .env file in root directory then add below line in the .env file

 SKIP_PREFLIGHT_CHECK=true 

Upvotes: 4

Rida Rezzag
Rida Rezzag

Reputation: 3953

I couldn't find a way to uninstall the whole node module folder the only way is to delete the whole file using command line

rm -rf node_modules

Upvotes: 0

dragonfly
dragonfly

Reputation: 3227

I encountered the same issue and following worked for me:

  • Delete the node-modules folder and package-lock.json file
  • Downloaded and installed Node.js
  • npm install [email protected]
  • npm install [email protected]
  • Deleted babel-eslint entry from package.json
  • Used this command on the project folder: npm install
  • Finally yarn start or npm start

Upvotes: 1

Serkan AKMAN
Serkan AKMAN

Reputation: 1133

If someone still facing this issue and uses yarn instead of npm can do (I am a mac user):

  • Open a terminal
  • Type yarn remove webpack
  • Come in to your project directory using your file explorer
  • Delete everything there
  • Open your code-editor
  • Delete hidden filers (ETC: .env or .gitignore files) if exists
  • In your project directory open a terminal and type npx create-react-app . and hit enter.
  • And restart the app typing yarn start after download.

It worked for me. It downloaded the web pack which is needed from react-scripts.

Upvotes: 1

Afroz Atoz
Afroz Atoz

Reputation: 41

Go to /home/hanna and type npm i webpack@required_dependency. It should solve your problem.

Upvotes: 1

Kranti Brid
Kranti Brid

Reputation: 31

Go to your project directory where you are running npm start and run the command

touch .env

If there is no pre-existing .env file in your project this will create it. Got to .env file and add the following code (if you are on LINUX box you do this by typing nano .env otherwise just use a text editor. SKIP_PREFLIGHT_CHECK=true

Save the file and try running npm start again. This solution is exactly what is suggested in the error message and it worked for me

Upvotes: 3

a_r_m
a_r_m

Reputation: 17

Due to newer versions, this worked for me:

  1. Open a terminal window (command prompt) 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 node_modules again

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

    npm install
    

Upvotes: 0

rodrigo rodrigues
rodrigo rodrigues

Reputation: 21

I think if you have a webpack package installed globally it might cause such error. Removing it globally might solve the problem. That's what I did here and it works.

Upvotes: 0

altostraus
altostraus

Reputation: 61

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

Worked afterwards.

Upvotes: 6

user9632291
user9632291

Reputation:

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.

Upvotes: 20

Ralf Hema
Ralf Hema

Reputation: 1

Your problem is you installed webpack version: 4.20.2

You need to install an earlier version "webpack": "4.19.1"`

enter image description here

Your problem is you installed webpack version: 4.20.2

You need to install an earlier version "webpack": "4.19.1"` ..So

$npm uninstall -g webpack

and

$npm install -g [email protected]

Hope that helps

Upvotes: 0

zetriks
zetriks

Reputation: 41

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.

Upvotes: 4

Sanjeet kumar
Sanjeet kumar

Reputation: 3441

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.

Upvotes: 27

Atav32
Atav32

Reputation: 1812

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.

Upvotes: 4

Related Questions