0

I am trying to watch only specific directories while starting node-dev because of the issue with multiple watches that causes; Error: watch /usr/src/app/node_modules/common-tags/lib/stripIndent/stripIndent.js ENOSPC

I tried passing the watch flag but, the process is not able to find the module;

node-dev --watch api app.js

It throws the below error:

Error: Cannot find module 'api' from '/usr/src/app'
    at resolveSync (/usr/src/app/node_modules/resolve/lib/sync.js:89:15)
    at module.exports (/usr/src/app/node_modules/node-dev/lib/resolve-main.js:4:10)
    at getConfig (/usr/src/app/node_modules/node-dev/lib/cfg.js:30:16)
    at module.exports (/usr/src/app/node_modules/node-dev/lib/cli.js:46:14)
    at Object.<anonymous> (/usr/src/app/node_modules/node-dev/bin/node-dev:11:5)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)

The api directory is present in /usr/src/app. I tried using the same watch flag with nodemon and it seems to work but it has its own set of issues and crashes when a file change occurs.

I tried putting the configuration in .node-dev.json, but there has been no impact.

{
  "watch": ["api"],
  "ignore": [
    "*.test.js",
    "assets/*",
    "coverage/*",
    "docs/*",
    "email_templates/*",
    "kubernetes/*",
    "logs/*",
    "node_modules/*",
    "queue/*",
    "script/*",
    "shared/*",
    "tasks/*",
    "test/*",
    "tests/*",
    "uitests/*",
    "views/*"
  ]
}

Please note that I cannot modify fs.inotify.max_user_watches as the VM is shared and I don't have permission to run system commands.

Any help would be highly appreciated.

  • you are not passing a js file to the watch parameter, *api* is a folder, not a module. try ```node-dev --watch api/app.js``` – Victor_Maciel Sep 30 '20 at 04:39
  • but the idea is to watch an entire directory (or directories), I tried something like `node-dev --watch api/*.js app.js` – coderHASH64codingHASH46code Sep 30 '20 at 04:42
  • the node-dev module does not scan for file to be watched. Its receive one root file and and just watch the files that are explicitly required. Font: https://www.npmjs.com/package/node-dev – Victor_Maciel Sep 30 '20 at 05:01
  • thanks, @Victor_Maciel, the problem is that it is watching the entire source folder and the way we have structured it has all the front end and backend code. So, I was thinking, like `nodemon` if we can specify a directory to watch, it would be great. I am not sure why the `.node-dev.json` changes are being taken into effect. Breaking my head stackoverflow posts to github posts – coderHASH64codingHASH46code Sep 30 '20 at 07:15

0 Answers0