Skip to content

"Cannot read property 'match' of undefined" on ng build --prod after updating to 6.0.0-rc.* #10231

Closed

Description

@julianobrasil

Versions

Angular CLI: 6.0.0-rc.2
Node: 8.11.1
OS: win32 x64
Angular: 6.0.0-rc.3
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

@angular/cdk: 6.0.0-rc.1
@angular/cli: 6.0.0-rc.2
@angular/flex-layout: 5.0.0-beta.14
@angular/material-moment-adapter: 6.0.0-rc.1
@angular/material: 6.0.0-rc.1
@angular-devkit/architect: 0.5.4
@angular-devkit/build-angular: 0.5.4
@angular-devkit/core: 0.5.4
@angular-devkit/schematics: 0.5.4
@ngtools/json-schema: 1.1.0
@schematics/angular: 0.5.4
@schematics/update: 0.5.4
typescript: 2.7.2
webpack: 4.5.0

Repro steps

I'm not sure if the steps below are necessary to see the bug happening in Windows 10 system. These are the steps I did on my machine, and since 6.0.0-rc.0 I cannot perform ng build --prod.

  • Migrate a project from earlier versions to 6.0.0-rc.0 (installing cli also globally)
  • ng update @angular/cli --migrate-only --from=1.7.1
  • upgrade cli to 6.0.0-rc.1 and then 6.0.0-rc.2
  • Try to ng build --prod

If it helps, the project I used in the tests: https://github.com/julianobrasil/material2-test

Observed behavior

Cannot read property 'match' of undefined
TypeError: Cannot read property 'match' of undefined
    at Object.normalize (E:\******\node_modules\@angular-devkit\build-angular\node_modules\@angular-devkit\core\src\virtual-fs\path.js:178:14)
    at options.fileReplacements.forEach (E:\******\node_modules\@angular-devkit\build-angular\src\browser\index.js:99:55)
    at Array.forEach (<anonymous>)
    at BrowserBuilder.buildWebpackConfig (E:\******\node_modules\@angular-devkit\build-angular\src\browser\index.js:98:34)
    at Observable.rxjs_1.Observable.obs [as _subscribe] (E:\******\node_modules\@angular-devkit\build-angular\src\browser\index.js:31:38)
    at Observable.subscribe (E:\******\node_modules\rxjs\internal\Observable.js:162:69)
    at E:\******\node_modules\rxjs\internal\util\subscribeTo.js:22:31
    at Object.subscribeToResult (E:\******\node_modules\rxjs\internal\util\subscribeToResult.js:7:45)
    at MergeMapSubscriber._innerSub (E:\******\node_modules\rxjs\internal\operators\mergeMap.js:132:38)
    at MergeMapSubscriber._tryNext (E:\******\node_modules\rxjs\internal\operators\mergeMap.js:129:14)
    at MergeMapSubscriber._next (E:\******\node_modules\rxjs\internal\operators\mergeMap.js:112:18)
    at MergeMapSubscriber.Subscriber.next (E:\******\node_modules\rxjs\internal\Subscriber.js:103:18)
    at MergeMapSubscriber.notifyNext (E:\******\node_modules\rxjs\internal\operators\mergeMap.js:141:26)
    at InnerSubscriber._next (E:\******\node_modules\rxjs\internal\InnerSubscriber.js:30:21)
    at InnerSubscriber.Subscriber.next (E:\******\node_modules\rxjs\internal\Subscriber.js:103:18)
    at MergeMapSubscriber.notifyNext (E:\******\node_modules\rxjs\internal\operators\mergeMap.js:141:26)

Desired behavior

Run ng build --prod without errors

Mention any other details that might be useful (optional)

As the error message mentions rxjs a lot, I think it's worth to tell my rxjs versions:

"rxjs": "6.0.0-rc.1"
"rxjs-compat": "6.0.0-rc.1"

Activity

  1. julianobrasil commented on Apr 8, 2018

    @julianobrasil
    Author

    Apparently the migration process (--migrate-only), generated the following snippet in angular.json in the "configurations.production" attribute (you can check for it in the repo link I've posted above):

    "fileReplacements": [
      {
        "from": "src/environments/environment.ts",
        "to": "dist/undefined"
      }
    ]

    I've tried (unsuccessfully) to replace it for:

    "fileReplacements": [
      {
        "from": "src/environments/environment.ts",
        "to": "dist/environments/environment.prod.ts"
      }
    ]

    After checking out a brand new generated project, I've switched it to:

    "fileReplacements": [
       {
         "src": "src/environments/environment.ts",
         "replaceWith": "src/environments/environment.prod.ts"
       }
    ]

    Now it's compiling again with ng build --prod.

    cc: @filipesilva

  2. filipesilva commented on Apr 9, 2018

    @filipesilva
    Contributor

    Heya, I believe you ran into #10141. It was fixed for upgrading projects in rc.1 (or maybe 2).

  3. Mathem8tic commented on Apr 9, 2018

    @Mathem8tic

    I had the exact same issue. Seems fixed in rc.2. Just create new from the CLI rc.2 and reintegrate your files.

  4. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  5. locked and limited conversation to collaborators on Sep 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions