React js npm start error

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

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:

  C:\Users\efe\Desktop\felt-pine\node_modules\webpack (version: 5.11.0)

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

If you would 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:

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

  6. Check if C:\Users\efe\Desktop\felt-pine\node_modules\webpack is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

  7. 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! felt-pine@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the felt-pine@0.1.0 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!     C:\Users\efe\AppData\Roaming\npm-cache\_logs\2020-12-20T13_04_13_341Z-debug.log

it gives this error how can i solve this error i was install the webpack to enable the css modules now it doesnt start

Have you tried following the instructions given in the error message? If you installed another version of webpack, most likely there is a conflict with the version required by CRA.

i did the instructions but nothing happened how can i delete the webpack and install the new one that is compatible with the react and css modules?

It’s saying that you’ve manually installed webpack somewhere else in your project, why? If you’re saying you’ve followed the instructions and you’re getting the same error, then what is the structure of your project? If you explicitly tell npm to ignore the issue by adding that line to a .env file, do you still get the error?

The instructions there specify what to do: if you’ve installed webpack in a project, then delete node modules, the package lock and the line in package.json (or run npm uninstall webpack which does the same thing).

i installed it with npm is it manual

Yes, if you installed webpack yourself, that would be you installing it manually. Why did you install it though? The error you are getting is because Create React App already has Webpack as a dependency, so you are installing it twice in the same project (and installing different versions, which is the root cause of the error)

i installed it because i was trying to enable css modules what should i do right now i did the everthing that the npm said but it didnt wok out for me should i create a new app and replace the pages because i was done that before the css loader was dead .

CSS modules are supported out of the box by Create React App, you don’t need to install anything except CRA, you don’t need a loader because there’s a loader already there in CRA’s own Webpack config.

ok im going to create a new react app and replace the files and do things you said thanks for everything dan.

1 Like

I found that for some reason, I had the node_modules directory installed in my HOME folder. I blew that away and everything is AOK when I run npm install in the local project folders now.

n the terminal, run:

cd ~

Then:

ls

You should see a list of files. If node_modules is included in that list (as it appears it should be), you want to delete that folder. You can do so in the terminal like so:

rm -rf node_modules

But keep in mind: this will not send the folder to the trash. It will irrevocably delete it. rm -rf is a powerful command. If that makes you nervous, type open . instead. That will open your “home” ( ~ ) directory in Finder, and you can delete node_modules in the familiar, right-click, send-to-trash way there.

Hope that helps!