question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React-scripts and another package pulling in different versions of webpack

See original GitHub issue

Hi all, I had a working react app that today I upgraded some packages on. And now when I try to start it up I get the following (I replaced some identifying stuff with β€˜*****’):

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:

  /Users/*****/Dev/nodejs/*****/client/node_modules/webpack (version: 4.29.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 /Users/*****/Dev/nodejs/*****/client/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.

I tried all of the steps, including switching over to yarn (I was using npm). However, the problem persists. Here is the result of npm ls webpack:

$ npm ls webpack
client@0.1.0 /Users/*****/Dev/nodejs/*****/client
β”œβ”€β”¬ cra-universal@4.2.0
β”‚ └── webpack@4.29.0 
└─┬ react-scripts@2.1.3
  β”œβ”€β”¬ css-loader@1.0.0
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ eslint-loader@2.1.1
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ file-loader@2.0.0
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ fork-ts-checker-webpack-plugin-alt@0.4.14
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ html-webpack-plugin@4.0.0-alpha.2
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ mini-css-extract-plugin@0.4.3
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ optimize-css-assets-webpack-plugin@5.0.1
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ sass-loader@7.1.0
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ terser-webpack-plugin@1.1.0
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ url-loader@1.1.1
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ webpack@4.19.1 
  β”‚ └─┬ uglifyjs-webpack-plugin@1.3.0
  β”‚   └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ webpack-dev-server@3.1.14
  β”‚ └── webpack@4.29.0  extraneous
  β”œβ”€β”¬ webpack-manifest-plugin@2.0.4
  β”‚ └── webpack@4.29.0  extraneous
  └─┬ workbox-webpack-plugin@3.6.3
    └── webpack@4.29.0  extraneous

npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/css-loader/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/eslint-loader/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/file-loader/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/fork-ts-checker-webpack-plugin-alt/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/html-webpack-plugin/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/mini-css-extract-plugin/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/optimize-css-assets-webpack-plugin/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/sass-loader/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/terser-webpack-plugin/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/url-loader/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/uglifyjs-webpack-plugin/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/webpack-dev-server/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/webpack-manifest-plugin/node_modules/webpack
npm ERR! extraneous: webpack@4.29.0 /Users/*****/Dev/nodejs/*****/client/node_modules/react-scripts/node_modules/workbox-webpack-plugin/node_modules/webpack

I also tried npm prune to no avail. Any ideas how I can resolve this properly?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
bugzpoddercommented, Jan 24, 2019

You should be able to use yarn resolutions to ping webpack to a specific version: https://yarnpkg.com/lang/en/docs/selective-version-resolutions/

0reactions
zamirkhancommented, Jan 28, 2019

You should be able to use yarn resolutions to ping webpack to a specific version: https://yarnpkg.com/lang/en/docs/selective-version-resolutions/

This worked well. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resolving multiple versions of React in component library ...
Currently, I'm just pulling it in from Github, but this should work released to NPM or a private package repository. The consuming/receiving appΒ ......
Read more >
react-scripts - npm Package Health Analysis
Ensure you're using the healthiest npm packages. Snyk scans all the packages in your projects for vulnerabilities and provides automated fix advice.
Read more >
Everything you need to know about react-scripts
Even though Create React App provides four preconfigured scripts, you can add more scripts by updating your package.json file like any other ......
Read more >
A Guide to Managing Webpack Dependencies
The Webpack module bundler processes JavaScript code and all static assets, such as stylesheets, images, and fonts. However, configuring Webpack and itsΒ ...
Read more >
Code-Splitting
Most React apps will have their files β€œbundled” using tools like Webpack, Rollup or Browserify. Bundling is the process of following imported files...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found