Unable to --watch directory with node-dev

225 views Asked by At

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.

0

There are 0 answers