Skip to content

ng serve watch capability and ng build --aot capability for symbolically linked modules on Windows machines. #7224

Closed

Description

@hieuxlu

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.2.0
node: 8.1.2
os: win32 x64

Repro steps.

  1. Clone https://github.com/johnpapa/angular-tour-of-heroes.git
  2. Separate Heroes module into modules folder
+---.vscode
+---e2e
+---modules
|   \---heroes
\---src
    +---app
    +---assets
    \---environments
  1. Create heroes package.json in modules/heroes
npm init heroes
  1. Create a symbolic link/junction from node_modules/heroes to modules/heroes folder
mklink /J "node_modules/heroes" "modules/heroes"
  1. Add reference to project's main package.json
 "dependencies": {
    ...
    "heroes": "*"
  },

5.1 Run ng serve
5.2 Run ng build --aot

The log given by the failure.

5.1. Run ng serve

Failed to compile.

./modules/heroes/heroes.component.ts
Module build failed: Error
    at WebpackCompilerHost.populateWebpackResolver (G:\GIT\Angular\angular-tour-of-heroes\node_modules\@ngtools\webpack\src\compiler_host.js:135:51)
    at _donePromise.Promise.resolve.then.then.then.then.then (G:\GIT\Angular\angular-tour-of-heroes\node_modules\@ngtools\webpack\src\plugin.js:371:32)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:169:7)
 @ ./modules/heroes/heroes.module.ts 11:0-53
 @ ./src async
 @ ./~/@angular/core/@angular/core.es5.js
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts

5.2. Run ng build --aot

ERROR in Cannot determine the module for class HeroDetailComponent in G:/GIT/Angular/angular-tour-of-heroes/src/app/components/her
o-detail/hero-detail.component.ts! Add HeroDetailComponent to the NgModule to fix it.

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'G:\GIT\Angular\angular-tour-of-heroes\src'
 @ ./src/main.ts 3:0-74
 @ multi ./src/main.ts

Desired functionality.

ng serve watch and ng build --aot capability for symbolically linked modules on Windows machines.
This does not seem to be an issue on Linux machines.

Mention any other details that might be useful.

The same issues also occurs with modules linked by lerna. For example:
https://github.com/OasisDigital/scalable-enterprise-angular.git

Activity

  1. hieuxlu commented on Aug 1, 2017

    @hieuxlu
    Author

    Known workaround for issue 5.1 with ng serve

    1. Switch to webpack build with ng eject
    2. Change modules-> symlinks values in webpack.config.js to false
    module.exports = {
      ...
        "modules": [
          "./node_modules",
          "./node_modules"
        ],
        "symlinks": false
      },
    
  2. filipesilva commented on Aug 2, 2017

    @filipesilva
    Contributor

    I believe the --preserve-symlinks already solves this (#6460).

  3. hieuxlu commented on Aug 4, 2017

    @hieuxlu
    Author

    @filipesilva Thanks for your prompt response. I have updated to @angular/cli@latest, which had the fix you mentioned.

    ng serve --preserve-symlinks=true does not watch changes in the symbolic linked folder anymore. Is this is an intended effect?

    ng build --prod --preserve-symlinks=true & ng build --prod still failed though.

    Error log

    ERROR in ./src/$$_gendir async
    Module not found: Error: Can't resolve 'G:\GIT\Angular\angular-tour-of-heroes\src\node_modules\heroes\heroes.module.ngfactory.ts'
    in 'G:\GIT\Angular\angular-tour-of-heroes\src\$$_gendir'
     @ ./src/$$_gendir async
     @ ./~/@angular/core/@angular/core.es5.js
     @ ./src/main.ts
     @ multi ./src/main.ts
    
  4. filipesilva commented on Aug 10, 2017

    @filipesilva
    Contributor

    That particular side effect intended per se... but it is by design, in a way. You can find more information about the problems in that sort of setup in #6387 (comment) and #6228 (comment).

  5. angular-automatic-lock-bot commented on Sep 7, 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.

  6. locked and limited conversation to collaborators on Sep 7, 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