React-scripts and another package pulling in different versions of webpack
See original GitHub issueHi 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:
- Created 5 years ago
- Comments:7
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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!