Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code: Unable to watch for file changes. Why?

I often get the "Visual Studio Code is unable to watch for file changes in this large workspace" -error and I can't figure out why.

Visual Studio Code (Linux): 1.24.1

My exclude setting is:

"files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/*/**": true,
    "**/.svn/**": true,
    "**/dist/**": true,
    "**/dist-prod/**":true
}

The structure of the project is:

angular.json
/dist
/dist-prod
/e2e
ngsw-config.json
/node_modules
package.json
package-lock.json
proxy.conf.json
README.md
/src
tsconfig.json
tslint.json
xliffmerge.json
.editorconfig
.gitignore
/.svn

/src contains only 167 files and folders. I suspect that node_modules is not really excluded. But I can't know for sure. Is my settings correct?

The problem goes away after VSC is restarted, but it always comes back after a while...

like image 473
Jette Avatar asked Aug 02 '18 06:08

Jette


People also ask

Why my VS Code is not working properly?

Common issues on Windows# You can check and disable compatibility mode by right-clicking on the VS Code executable and selecting properties, then uncheck the Run this program in compatibility mode option in the compatibility tab.

What does VS Code file watcher do?

File & Folder Watcher This extension allows configuring commands that get run whenever a file is saved or folder is changed in vscode.


1 Answers

you've to increase the limit. Follow the below procedure:

  1. Check the current limit cat /proc/sys/fs/inotify/max_user_watches
  2. edit sysctl.conf file in vim editor sudo vim /etc/sysctl.conf
  3. Add this line at bottom fs.inotify.max_user_watches=524288
  4. save it (esc) :wq!
  5. To load the change sudo sysctl -p
  6. now check again cat /proc/sys/fs/inotify/max_user_watches

if the count is same, execute the following command

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

For more details

Happy coding :)

like image 61
Anand Raja Avatar answered Oct 28 '22 02:10

Anand Raja