4

I tried implementing custom nodemon configuration in package.json as shown below:

"nodemonConfig": {
    "watch": ["server", "bin/www"],
    "ext": "ts",
    "ignore": ["*.test.ts"],
    "delay": "3000",
    "execMap": {
      "ts": "ts-node"
    }
  }

Yet, it didn't work. Nodemon doesn't restart when ./bin/www is edited, nor does ignoring the files that restart the server works.

Can anyone suggest me the correct nodemonConfig?

ankurnarkhede
  • 378
  • 1
  • 4
  • 9

3 Answers3

3

I think these settings only work when npm is starting nodemon, something like

// package.json
"scripts": {
  "start:dev": "DEBUG=app:* nodemon app.js"
}

then use

$> npm run start:dev

William Vbl
  • 503
  • 3
  • 8
1

package.json

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node index.js",
    "dev": "nodemon index.js"
  },

Terminal

npm run dev
0

You were close. First piece of advice is when you're having issues, add the verbose flag.

Second, although you correctly configured nodemon options and mappings, you still need to tell it what to execute (bin/www).

Your package.json should look like this:

{
  "scripts": {
    "dev": "nodemon bin/www"
  },
  "nodemonConfig": {
    "verbose": true,
    "watch": ["server", "bin/www"],
    "ext": "ts",
    "ignore": ["*.test.ts"],
    "delay": "3000",
    "execMap": {
      "ts": "ts-node"
    }
  }
}

Note: execMap already defaults to ts-node, see defaults.js.

Subfuzion
  • 1,789
  • 20
  • 18