'How to run prettier automatically in Nuxt.JS

Using Nuxt.JS, while on development with npm run dev, I want to trigger the command npm run prettier automatically when saving, to keep the code clean.

In any other project, I would achieve this with Nodemon with the following nodemon.json:

{
  "events": {
    "restart": "npm run prettify"
  }
}

However Nuxt.JS doesn't seem to use Nodemon and/or it does not expose any "on change" event either.

How can I run a custom script when Nuxt.JS reloads?

Note: Looking for a solution not dependent on VSCode.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source