Angular-cli serve watch not work under vagrant win

2019-07-02 01:58发布

问题:

I have windows 10 host and Ubuntu 14.04 LTS under vagrant box. Shared folder with symlink permissions

config.vm.synced_folder "project_folder", "/home/vagrant/ngbox_project", type: "smb", mount_options: ["vers=3.02","mfsymlinks"]

Installed npm, angular-cli

npm 4.0.5

angular-cli: 1.0.0-beta.24
node: 4.7.0
os: linux x64
@angular/common: 2.4.1
@angular/compiler: 2.4.1
@angular/core: 2.4.1
@angular/forms: 2.4.1
@angular/http: 2.4.1
@angular/platform-browser: 2.4.1
@angular/platform-browser-dynamic: 2.4.1
@angular/router: 3.4.1
@angular/compiler-cli: 2.4.1

Everything worked fine axcept ng serve not watch file changed at windows (via shared folder). If changes make at Ubuntu serve watch work. Соответственно Also not work build --watch eth

When i used webpack-dev-server (angular2 + webpack) installed manually not from ng-cli - watch work normally in both systems

trying sudo sysctl fs.inotify.max_user_watches=524288 it doesn't help me.

P.S. I tryed to reinstall npm, ng-cli with cache remove. Shared folder path has not spaces.

回答1:

Edit: Rsync only allows one-way synchronization (see https://github.com/mitchellh/vagrant/issues/3062). So it is no good for working with angular-cli. Pardon me. Below you find a solution that should work.

Working Solution

Use the vagrant plugin fsnotify. It watches for changes on your host and repeats them on the guest.

Not working solution

  • Rsync type for shared folders in vagrant
    • only one-way-synchronization
  • vagrant-sshfs plugin
    • mounting doesn't work at all (for me)