Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

watchpack watch not triggering when symlinked node_module files are modified when using webpack 'symlinks: true' #61

txinfo opened this issue Jan 16, 2018 · 10 comments


Copy link

@txinfo txinfo commented Jan 16, 2018

In a regular webpack project, a symlinked module in node_modules is watched for changes correctly (as long as the module in question is referenced).

However, if using 'symlinks:true' in webpack to resolve symlinks to their full path (e.g. when using --preserve-symlinks behaviour in angular-cli), it does not seem to watch for changes anymore.

I have tracked this behaviour down to the 'followSymlinks' option of DirectoryWatcher in watchpack ( The followSymlinks option is always set to false which causes an issue with file watching when webpack is set to resolve symlinks. If it is manually set to true in this scenario, the watching works. Ideally this option would be configurable.

Copy link

@jukibom jukibom commented Jan 19, 2018

Yep, I'm seeing this exact problem with an angular 5 app and a linked node library I'm working on. Manually setting the flag works correctly.

Copy link

@jukibom jukibom commented Jul 11, 2018

anyone looking for a horrifying stopgap waiting for this to be fixed, add
"postinstall": "sed -i 's/followSymlinks: false/followSymlinks: true/g' node_modules/watchpack/lib/DirectoryWatcher.js"
to package.json. Probably don't commit it into your repo though ;P

Copy link

@svilendobrev svilendobrev commented Aug 29, 2018

same finding here, with same fix, for the same problem in opposite setup... bunch of symlinked files (under webpack + resolve.symlink=false) are not noticed for being changed.. because the actual links do not change. the followSymlinks:true fixes that.

Copy link

@liujingbreak liujingbreak commented Nov 2, 2018

Me, another Angular 7 developer facing same problem.
It has been 10 months...

Copy link

@needo2 needo2 commented Nov 22, 2018

Experiencing this with 'symlinks: false'

Copy link

@LaKing LaKing commented Dec 9, 2018

Finally I found this. Fix from @jukibom works!

Copy link

@floribon floribon commented Dec 12, 2018

I'm also having this problem when I symlink a folder in my node_modules and use symlinks: false.

@jukibom workaround works for now. Thanks!

Copy link

@bkniffler bkniffler commented Jun 2, 2019

Just in case @jukibom command doesn't work on your platform, you can install replace package from npm globally or locally and add this in postinstall.

replace 'followSymlinks: false' 'followSymlinks: true' node_modules/watchpack/lib/DirectoryWatcher.js

Its 100% analog to @jukibom solution, so all credits to him!

Copy link

@raf64flo raf64flo commented Jun 12, 2019

I fear @jukibom's workaround is not working anymore since commit 805b665 which removes dependency to chokidar and symlinks configuration..

@sokra any chance to have a symlink option with the new native watcher, before v2.0.0 goes GA?

Copy link

@cristian-spiescu cristian-spiescu commented Jan 19, 2020

  1. Even if this issue is closed by @sokra following the merge of a pull request that seems to fix the issue, the issue still exists. I.e. in webpack, there is still no way to pass the followSymlinks option.
  2. @raf64flo, in my case @jukibom's fix still works. At time of writing I use webpack 4.41.0.
  3. I built upon @jukibom's suggestion in order to perform the modification at runtime, via monkeypatching, and have a "less temporary" temporary code:
var Module = require('module');
var originalRequire = Module.prototype.require;

Module.prototype.require = function () {
  const original = originalRequire.apply(this, arguments);
  if ("chokidar" === arguments[0]) {
    var originalWatch =; = function () {
      const options = arguments[1];
      if (options) {
        options.followSymlinks = true;

      return originalWatch.apply(this, arguments);
  return original;

This piece of code should execute early, in the start script which ultimately launches webpack. In my case, I use, so I put it in craco.config.js which is getting called quite early.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

10 participants