Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack bug locally #8847

Closed
prandogabriel opened this issue Apr 17, 2020 · 2 comments
Closed

webpack bug locally #8847

prandogabriel opened this issue Apr 17, 2020 · 2 comments

Comments

@prandogabriel
Copy link

I have this problem, I tried all the steps and nothing solved

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

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/prando/node_modules/webpack (version: 4.39.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:

  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/prando/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!

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@seleckis
Copy link

I have the same problem. npm ls webpack gives me this answer:

├─┬ @storybook/react@5.3.18
│ ├─┬ @storybook/core@5.3.18
│ │ ├─┬ corejs-upgrade-webpack-plugin@2.2.0
│ │ │ └── webpack@4.42.1  deduped
│ │ └── webpack@4.42.1  deduped
│ └── webpack@4.42.1
└─┬ react-scripts@3.4.1
  └── webpack@4.42.0

So storybook has newer webpack and it conflicts with react-script's webpack version. As a solution may be to update webpack in react-scripts?

@Akivashi
Copy link

I have the same issue, but with a newer version of webpack, compared to what react-scripts is using. This isnt the first time i had this issue either when using react-scripts. Finding out the correct packages needed and locking them in place, instead of updating packages to latest version should not be the way to solve this, so i would also very much like a more long term solution.

My current dependency tree for webpack mentions these:

+-- react-scripts@3.4.1
| `-- webpack@4.42.0
`-- webpack@4.43.0

When using the following (relevant) package.json dependencies:

"react-scripts": "3.4.1",
"webpack": "^4.42.0",

Also note that, according to the semantic versioning rules by npm (found here), upgrading a minor release, should be backwards compatible with previous version, which apparently is not the case for react-scripts.

@lock lock bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants