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.

custom-webpack:server errors with Cannot read properties of undefined (reading 'colors')

See original GitHub issue

Describe the Bug

When using the @angular-builders/custom-webpack:server builder, it is erroring with the following error.

TypeError: Cannot read properties of undefined (reading 'colors')
    at statsToString (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-angular/src/webpack/utils/stats.js:193:32)
    at webpackStatsLogger (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-angular/src/webpack/utils/stats.js:374:17)
    at MergeMapSubscriber.project (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-angular/src/builders/server/index.js:93:44)
    at MergeMapSubscriber._tryNext (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/operators/mergeMap.js:67:27)
    at MergeMapSubscriber._next (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/operators/mergeMap.js:57:18)
    at MergeMapSubscriber.Subscriber.next (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/Subscriber.js:66:18)
    at SafeSubscriber.__tryOrUnsub (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-webpack/node_modules/rxjs/internal/Subscriber.js:205:16)
    at SafeSubscriber.next (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-webpack/node_modules/rxjs/internal/Subscriber.js:143:22)
    at Subscriber._next (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-webpack/node_modules/rxjs/internal/Subscriber.js:89:26)
    at Subscriber.next (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-webpack/node_modules/rxjs/internal/Subscriber.js:66:18)
    at SwitchMapSubscriber.notifyNext (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-webpack/node_modules/rxjs/internal/operators/switchMap.js:85:26)
    at SimpleInnerSubscriber._next (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-webpack/node_modules/rxjs/internal/innerSubscribe.js:27:21)
    at SimpleInnerSubscriber.Subscriber.next (/Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-webpack/node_modules/rxjs/internal/Subscriber.js:66:18)
    at /Users/zach.morgan/Development/mfe-universal/node_modules/@angular-devkit/build-webpack/src/webpack/index.js:58:25
    at /Users/zach.morgan/Development/mfe-universal/node_modules/webpack/lib/HookWebpackError.js:68:3
    at Hook.eval [as callAsync] (eval at create (/Users/zach.morgan/Development/mfe-universal/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)

If I dont specify a customWebpackConfig, it works fine. However, as soon as I specify one, it errors. Even if the custom webpack config is essentially empty.

Minimal Reproduction

I kept the original server target and created a server-custom target for the repro.

https://github.com/sir-captainmorgan21/angular-builders-custom-webpack-sever-repro

Expected Behavior

I’d expect this to run without errors.

Environment


Libs
- @angular/core version: ~14.2.0
- @angular-devkit/build-angular version: ~14.2.0
- @angular-builders/custom-webpack version: ^14.0.1

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
arturovtcommented, Nov 14, 2022

It merges when it exports an object, but it doesn’t merge when it exports a factory function:

If customWebpackConfig.path file exports a function, the behaviour of the builder changes : no more automatic merge is applied, instead the function is called with the base Webpack configuration and must return the new configuration.

1reaction
sir-captainmorgan21commented, Nov 14, 2022

@just-jeb that was it. Thanks! I actually re-read through your docs, and was able to find that. May be a good place for a trouble shooting section though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read properties of undefined (reading 'color')
The browser is throwing an error TypeError: Cannot read properties of undefined (reading 'color') . Here is my utilities.js file which is ...
Read more >
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError : Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Cannot read properties of undefined (reading 'displayMode ...
What happened: A Grafana v8.3.6 to B Grafana v8.3.6 Panel JSON Error TypeError: Cannot read properties of undefined (reading 'displayMode') ...
Read more >
Uncaught TypeError : Cannot read properties of undefined
Looking for ways to handle Uncaught TypeError: Cannot read property of undefined in JavaScript? This guide will help you to catch errors.
Read more >
KB303816: "Cannot read property 'layouts' of undefined" error ...
When users create a Financial Reporting dashboard and selecting a large amount of elements from a hierarchy in the filter panel e.g. >...
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