Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I monitor symlinked modules with Nodemon?

I’m developing a module in Node.js which I’ve npm-linked into another projects node_modules folder. I’d like to restart this other projects server upon file changes in my module. Nodemon ignores node_modules by default, but I assumed I could override this using nodemon --watch node_modules/my_module – but can’t get it to work. If I temporarily remove node_modules from Nodemons lib/config/defaults.js it works, which probably confirms that the problem has to do with overriding default behavior.

like image 484
Victor Nystad Avatar asked May 04 '15 12:05

Victor Nystad


People also ask

Does Nodemon work with TS?

19.0, nodemon has inbuilt support for TypeScript files with help from ts-node that requires no manual configuration. By default, nodemon uses the node CLI as an execution program for running JavaScript files; for TypeScript files, nodemon uses ts-node as the execution program instead.

Where can I find Nodemon json?

nodemon supports local and global configuration files. These are usually named nodemon. json and can be located in the current working directory or in your home directory. An alternative local configuration file can be specified with the --config option.

Can Nodemon be used in production?

You don't need nodemon in production, nodemon it's only used for development purposes.


1 Answers

Using nodemon 1.2.1, I'm able to do the following to get watches working with an npm link:

$ nodemon --watch . --watch $(realpath node_modules/my_module)

Basically...you have to watch the directory you're in (your project directory), and then specify a watch to the symlink itself. nodemon by default ignores node_modules, so explicitly specifying the watch fixes this. You may try updating your version of nodemon if this doesn't work for you.

like image 154
jedd.ahyoung Avatar answered Sep 29 '22 19:09

jedd.ahyoung