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.

TypeError: Cannot read properties of undefined (reading 'match') when running application

See original GitHub issue

Which @angular/* package(s) are the source of the bug?

compiler, Don’t known / other

Is this a regression?

Yes

Description

After upgrading to Angular 13, I have started seeing this error whenever I start up the application:

TypeError: Cannot read properties of undefined (reading 'match')
    at extractCommentsWithHash (:5000/vendor.js:290935)
    at ShadowCss.shimCssText (:5000/vendor.js:290454)
    at :5000/vendor.js:306725
    at Array.map (<anonymous>)
    at compileStyles (:5000/vendor.js:306724)
    at compileComponentFromMetadata (:5000/vendor.js:306169)
    at CompilerFacadeImpl.compileComponentFromMeta (:5000/vendor.js:306920)
    at CompilerFacadeImpl.compileComponent (:5000/vendor.js:306908)
    at Function.get (:5000/vendor.js:348767)
    at getComponentDef (:5000/vendor.js:321523)

I believe this might be regression as I have seen other tickets mention this issue, but most of them say that the culprit is the existence of module: commonjs in the tsconfig file, but this is not the case for me.

I have also manually modified the angular.json file to explicitly say that I am using scss, but the error still persists, and only at runtime.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

TypeError: Cannot read properties of undefined (reading 'match')
    at extractCommentsWithHash (:5000/vendor.js:290935)
    at ShadowCss.shimCssText (:5000/vendor.js:290454)
    at :5000/vendor.js:306725
    at Array.map (<anonymous>)
    at compileStyles (:5000/vendor.js:306724)
    at compileComponentFromMetadata (:5000/vendor.js:306169)
    at CompilerFacadeImpl.compileComponentFromMeta (:5000/vendor.js:306920)
    at CompilerFacadeImpl.compileComponent (:5000/vendor.js:306908)
    at Function.get (:5000/vendor.js:348767)
    at getComponentDef (:5000/vendor.js:321523)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 13.0.3
Node: 16.13.0
Package Manager: npm 8.1.3
OS: win32 x64

Angular: 13.0.2
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1300.3
@angular-devkit/build-angular   13.0.3
@angular-devkit/core            13.0.3
@angular-devkit/schematics      13.0.3
@angular/cli                    13.0.3
@schematics/angular             13.0.3
rxjs                            6.6.7
typescript                      4.4.4

Anything else?

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
alan-agius4commented, Nov 30, 2021

If you don’t have any module set it will default to commonjs if the syntax target is es5 or lower.

Can you try to set the module to es2020 in your root level tsconfig?

1reaction
jethas-bennettjonescommented, Nov 26, 2021

For reference the CJS issue mentioned above is angular/angular-cli#21588

Thanks for linking the tickets, Alan. I had initially come across this ticket, but removing all of the CommonJS references I could find didn’t resolve my issue. I’ll try to get a minimum repro done today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read properties of undefined (reading 'match')
I have managed to tsolve the issue by setting in my tsconfig.json "target": "es2020", tsconfig.app.json "module": "es2020", tsconfig.spec.json " ...
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 property .match of undefined - Heroku Help
Running an npm command, such as npm install or npm ci , may raise something like this: npm err TypeError: Cannot read property...
Read more >
Cannot read properties of undefined (reading 'match')
Hey devs what could be reason of this error when interacting with smart contract? Cannot read properties of undefined (reading 'match').
Read more >
How to Avoid the Infamous "Cannot read properties of ... - Bitovi
That error message is telling you the function is returning undefined implicitly, but its return type does not include undefined in it. Awesome!...
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