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

typeof statsOptions.colors ... Cannot read property 'colors' of undefined #815

Closed
uinika opened this issue Jan 13, 2021 · 8 comments · Fixed by #816
Closed

typeof statsOptions.colors ... Cannot read property 'colors' of undefined #815

uinika opened this issue Jan 13, 2021 · 8 comments · Fixed by #816

Comments

@uinika
Copy link

uinika commented Jan 13, 2021

  • Operating System:
  • Node Version:
  • NPM Version:
  • webpack Version:
  • webpack-dev-middleware Version:

Expected Behavior

webpack built 4333dbf8aa8a0bbf4aab in 13716ms
C:\Workspace\gd-diy-apply\node_modules\webpack-dev-middleware\dist\utils\setupHooks.js:68
} else if (typeof statsOptions.colors === 'undefined' || typeof statsOptions === 'string') {
^

TypeError: Cannot read property 'colors' of undefined
at C:\Workspace\gd-diy-apply\node_modules\webpack-dev-middleware\dist\utils\setupHooks.js:68:38
at processTicksAndRejections (internal/process/task_queues.js:75:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./config/command/start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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\zhenghang\AppData\Roaming\npm-cache_logs\2021-01-13T06_27_35_802Z-debug.log

Actual Behavior

Code

// webpack.config.js
// If your code blocks are over 20 lines, please paste a link to a gist
// (https://gist.github.com).
// additional code, HEY YO remove this block if you don't need it

How Do We Reproduce?

@AviVahl
Copy link
Contributor

AviVahl commented Jan 13, 2021

same here, when using webpack@4 (works with webpack@5).

@alexander-akait
Copy link
Member

Somebody can create example?

@alexander-akait
Copy link
Member

@AviVahl I have added tests for webpack@4, but all fine 😕

@AviVahl
Copy link
Contributor

AviVahl commented Jan 13, 2021

Debugged to see what's happening during compilation.
compiler.options is defined. compiler.options.stats is not. This is causing statsOptions === undefined making statsOptions.colors blow up.
I'll try to create a reproduction.

@AviVahl
Copy link
Contributor

AviVahl commented Jan 13, 2021

mkdir issue-test
cd issue-test
npm init -y
npm i webpack@4 webpack-dev-middleware express

Now take code from readme and save as a.js:

const webpack = require('webpack');
const middleware = require('webpack-dev-middleware');
const compiler = webpack({
  // webpack options
});
const express = require('express');
const app = express();

app.use(
  middleware(compiler, {
    // webpack-dev-middleware options
  })
);

app.listen(3000, () => console.log('Example app listening on port 3000!'));

node a.js -> error occurs.

@alexander-akait
Copy link
Member

alexander-akait commented Jan 13, 2021

Yep, already found bug, WIP on this, anyway thanks for reproducible test repo, patch/release will be in near future

@alexander-akait
Copy link
Member

alexander-akait commented Jan 13, 2021

Please try https://github.com/webpack/webpack-dev-middleware/releases/tag/v4.0.4, I added all cases for stats, should be never broken again, I hope 😄

@AviVahl
Copy link
Contributor

AviVahl commented Jan 13, 2021

Works on my end. Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants