nodemon icon indicating copy to clipboard operation
nodemon copied to clipboard

Watch .cjs files by default

Open RobertSandiford opened this issue 3 years ago • 10 comments

"By default, nodemon looks for files with the .js, .mjs, .coffee, .litcoffee, and .json"

This seems like madness! : )

In an ES6 project I often have to use a .cjs file here or there. If nodemon is watching .mjs files by default why not .cjs files?

RobertSandiford avatar Nov 13 '21 08:11 RobertSandiford

Not sure why madness. The project was created over 11 years ago.

I've personally never used .cjs (nor .mjs, but I got a PR for support).

I'll leave this open for a while and if there's interest from others via 👍 then we can add it in. Otherwise it's a personal config setting.

remy avatar Nov 13 '21 11:11 remy

Sure, I understand. There's a reason for everything. It just seemed that way looking at it today.

It's a noob of a noob trap as it is. I figured it what it was in about 10 minutes (mixture of .js and .cjs in my project), but I can imagine quite a bit of frustration being caused by it.

I guess there are a host of other extensions that -could- be included. .jsx, .ts and .tsx come to mind.

RobertSandiford avatar Nov 13 '21 11:11 RobertSandiford

@RobertSandiford A quick solution would be to add a nodemon.json config file containing the extensions you want watching: {"ext": "js mjs cjs json"} I took that from this sample: https://github.com/remy/nodemon/wiki/Sample-nodemon.json , tested it and seems to be working: [nodemon] watching extensions: js,mjs,cjs,json

lorand-horvath avatar Nov 18 '21 08:11 lorand-horvath

@lorand-horvath or --ext=cjs,js

But just unnecessary to make people do that, hence the thread.

RobertSandiford avatar Nov 18 '21 08:11 RobertSandiford

@RobertSandiford Agreed, cjs could be added as default, I don't think it would create any issues. @remy PR added https://github.com/remy/nodemon/pull/1957 Hope I edited the proper location :)

lorand-horvath avatar Nov 18 '21 08:11 lorand-horvath

@RobertSandiford @remy It seems strange, but I've just tested the inline option below and it doesn't work with latest nodemon 2.0.15 nodemon --ext="js,mjs,cjs,json" index.js It returns: [nodemon] starting 'node --ext=js,mjs,cjs,json index.js' node: bad option: --ext=js,mjs,cjs,json Am I missing something?

lorand-horvath avatar Nov 18 '21 09:11 lorand-horvath

Space not the = symbol separates the arguments IIRC

remy avatar Nov 18 '21 09:11 remy

Yes, you are correct nodemon --ext js,cjs,mjs script

RobertSandiford avatar Nov 18 '21 09:11 RobertSandiford

This issue has been automatically marked as idle and stale because it hasn't had any recent activity. It will be automtically closed if no further activity occurs. If you think this is wrong, or the problem still persists, just pop a reply in the comments and @remy will (try!) to follow up. Thank you for contributing <3

github-actions[bot] avatar Jun 28 '22 10:06 github-actions[bot]

Am reviewing. Not totally sure about the PR (just to buy a little more time from stale-bot)

remy avatar Jul 12 '22 06:07 remy

Automatically closing this issue due to lack of activity

github-actions[bot] avatar Aug 11 '22 07:08 github-actions[bot]