Sitelet https://web.archive.org/web/20260420072006/https://github.com/angular/angular-cli/issues/21233
Skip to content

ng serve throwing error when pulling in files from outside the Angular project's root via file replacements #21233

@dezsiszabi

Description

@dezsiszabi

Bug Report

Affected Package

Not sure, but maybe @ngtools/webpack.

Is this a regression?

Yes, the previous version in which this bug was not present was: 11.0.9

Description

ng serve doesn't work when a file replacement containing a require is outside the project's workspace folder.

Minimal Reproduction

Please see the following repositories for reproduction:

Points of interests in the reproduction: angular.json file (fileReplacements) and app.module.ts.

Your Environment

Angular Version: 12.1.0




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 12.1.0
Node: 14.17.0
Package Manager: npm 6.14.13
OS: linux x64

Angular: 12.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.0
@angular-devkit/build-angular   12.1.0
@angular-devkit/core            12.1.0
@angular-devkit/schematics      12.1.0
@schematics/angular             12.1.0
rxjs                            6.6.7
typescript                      4.3.4

Anything else relevant?
I think I know how to fix it, I'm more interested in why this is happening. Was this an intended breaking change? Should the previous behavior be restored?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions