DEP_WEBPACK_WATCH_WITHOUT_CALLBACK after upgrading to webpack 5.x
See original GitHub issue- Operating System: macOS Catalina Version 10.15.7
- Node Version: v14.13.1
- NPM Version: 6.14.8
- webpack Version: 5.1.0
- webpack-dev-server Version: 3.11.0
- Browser: Not relevant
- This is a bug
- This is a modification request
Code
// webpack.config.js
// the config is not relevant in this case
// const webpackConfig = {};
const webpackDevConfig = {
...webpackConfig,
mode: 'development',
watch: true,
devtool: 'eval-cheap-module-source-map',
performance: {
hints: false,
},
};
const compiler = webpack(webpackDevConfig);
const devServerOptions = {
...webpackDevConfig.devServer,
contentBase: process.cwd() + `/serve/`,
watchContentBase: true,
publicPath: '/',
hot: true,
open: true,
stats: 'errors-warnings',
};
const server = new WebpackDevServer(compiler, devServerOptions);
server.listen(2020, '127.0.0.1');
Expected Behavior
Quiet as before upgrade to Webpack 5.x.
Actual Behavior
(node:96740) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
(Use `node --trace-deprecation ...` to show where the warning was created)
I got the warning above when running the code after upgrading to webpack 5.x. The code I use is basically copied from the official webpack website: https://webpack.js.org/api/node/
For Bugs; How can we reproduce the behavior?
For Features; What is the motivation and/or use-case for the feature?
Issue Analytics
- State:
- Created 3 years ago
- Comments:22 (8 by maintainers)
Top Results From Across the Web
To v5 from v4 - webpack
This guide aims to help you migrating to webpack 5 when using webpack directly. ... Upgrade all used Plugins and Loaders to the...
Read more >Compile error with Webpack 5 after upgrading but working ...
I have searched the issues of this repository and believe that this is not a duplicate.
Read more >Upgrading Webpack 4 → 5 | Square Corner Blog
Webpack 5 Gains · Decreased bundle size by 27-28% · Decreased build time by 10% (2m 54s → 2m 36s) · Cached dev...
Read more >After upgrading webpack to version 5 getting run time error ...
Webpack 4 used to shim Node globals like Buffer. Webpack 5 removed these polyfills: https://github.com/webpack/changelog-v5.
Read more >Webpack 5 Migration - Medium
Production build time is reduced by 27.5%, we can see improvement in build time ... Only then continue to upgrade to version 5...
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
Yes, you don’t need
watch: true
if you run watching (webpack --watch/webpack serve
), because it is unnecessary, you already watch itJust remove
watch: true
from your configuration