This forum has moved, please join us on github discussions. We will keep these old posts available for reference. Thank you!

Nodemon instead of node

In the tutorials, node app.js is always used to restart the app after changes.

I tried nodemon instead and have noticed that it restarts every time I reload the page or open/close an admin modal.

Is there a directory I have to exclude from watching? Nodemon should only reload after file changes (project level).

Could you include Nodemon in the tutorials? An alternative to reloading with node app.js all the time could be appreciated by new users.

I believe apostrophe will watch your templates for changes by default during development, but I’ve also used nodemon successfully in the past. Here’s an example command

Thank you, that was a good starting point.

After digging through the nodemon docs, I discovered verbose mode. Different files in the public directory trigger change checks on node startup and locales/en.json every time on page request. Learned something. :slight_smile:

I came up with the following config in package.json:

"nodemonConfig": {
  "verbose": true,
  "watch": ["app.js", "lib/modules"]
}

I still think it would be good to add nodemon to the tutorials. I will raise a PR.

Cool! I’m all in favor of adding a nodemon tutorial to the docs - seems like a common tool to be used in all node based projects. Didn’t really grasp why we would need verbose mode, but good to know that certain files are touched on every page request!

PR added!

That got me thinking: Do we need to touch the locales/en.json file on every page request? Does this affect performance if there are hundreds or thousands of translatable strings?

If this questions are stupid, forgive me. I am bloody new to Node.js and Apostrophe. :wink: