Skip to content

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

Closed

Description

@filipesilva

Versions

Angular CLI: 6.0.0-rc.0
Node: 8.11.0
OS: win32 x64
Angular: 6.0.0-rc.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 6.0.0-rc.0
@angular-devkit/architect: 0.0.10
@angular-devkit/build-angular: 0.0.10
@angular-devkit/build-optimizer: 0.4.9
@angular-devkit/core: 0.4.9
@angular-devkit/schematics: 0.5.0
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 6.0.0-beta.9
@schematics/angular: 0.5.0
@schematics/update: 0.5.0
typescript: 2.7.2
webpack: 4.1.0

Repro steps

  • Create new project with @angular/cli@1.7.3
  • Install @angular/cli@6.0.0-rc.0 globally and locally
  • Run ng update @angular/cli --migrate-only --from=1.7.1 inside project to update
  • Run ng build --prod

Observed behavior

$ ng build --prod
Cannot read property 'match' of undefined
TypeError: Cannot read property 'match' of undefined
    at Object.normalize (D:\sandbox\1.7-project\node_modules\@angular-devkit\build-angular\node_modules\@angular-devkit\core\src\virtual-fs\path.js:178:14)
    at options.fileReplacements.forEach (D:\sandbox\1.7-project\node_modules\@angular-devkit\build-angular\src\browser\index.js:99:55)
    at Array.forEach (<anonymous>)
    at BrowserBuilder.buildWebpackConfig (D:\sandbox\1.7-project\node_modules\@angular-devkit\build-angular\src\browser\index.js:98:34)
    at Observable.rxjs_1.Observable.obs [as _subscribe] (D:\sandbox\1.7-project\node_modules\@angular-devkit\build-angular\src\browser\index.js:31:38)
    at Observable.subscribe (D:\sandbox\1.7-project\node_modules\@angular-devkit\build-angular\node_modules\rxjs\internal\Observable.js:162:69)

Desired behavior

ng build --prod builds successfully.

Mention any other details that might be useful (optional)

This does not happen on a new rc.0 project.

A temporary workaround is to search your new angular.json file for

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

And replace it with

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

Activity

  1. filipesilva commented on Apr 4, 2018

    @filipesilva
    ContributorAuthor

    Fixed via angular/devkit#620, to be available on the next release.

  2. 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.

  3. 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