Nodemon: pstree vuln / pstree upgrade / Error: listen EADDRINUSE: address already in use

Created on 25 Nov 2018  Â·  28Comments  Â·  Source: remy/nodemon

  • nodemon -v: 1.18.6
  • node -v: 11.2.0
  • npm -v: 6.4.1
  • yarn -v: 1.12.3
  • OS / terminal: Ubuntu 18.10 cosmic (linux x64) / Bash
  • Command: nodemon -r ./lib app

I'm running into an EADDRINUSE error with nodemon and express since yesterday, which only happens when requiring a module (or file) using -r from the CLI.

Expected behaviour

It should restart the web server when the entry file is saved.

Actual behaviour

It hangs up with Error: listen EADDRINUSE: address already in use when the file is saved.

Steps to reproduce

  1. yarn init -y
  2. yarn add express and yarn add -D nodemon
  3. touch app.js and touch lib.js (_see file contents below_)
  4. dev script in package.json with nodemon -r ./lib app
  5. yarn dev
// app.js
require('express')().listen(3000, () => console.log('Works'))
// lib.js - empty
"scripts": {
  "dev": "nodemon -r ./lib app"
},
"dependencies": {
  "express": "^4.16.4"
},
"devDependencies": {
  "nodemon": "^1.18.6"
}

When I run yarn dev from the terminal, and then do Ctrl+S in app.js or lib.js in the editor, I get

yarn run v1.12.3
$ nodemon -r ./lib app
[nodemon] 1.18.6
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node -r ./lib app index.js`
Works
[nodemon] restarting due to changes...
[nodemon] starting `node -r ./lib app index.js`
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1294:14)
    at listenInCluster (net.js:1342:12)
    at Server.listen (net.js:1429:7)
    at Function.listen (/path/to/my/app/node_modules/express/lib/application.js:618:24)
    at Object.<anonymous> (/path/to/my/app/app.js:1:84)
    at Module._compile (internal/modules/cjs/loader.js:722:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
Emitted 'error' event at:
    at emitErrorNT (net.js:1321:8)
    at internalTickCallback (internal/process/next_tick.js:72:19)
    at process._tickCallback (internal/process/next_tick.js:47:5)
    at Function.Module.runMain (internal/modules/cjs/loader.js:778:11)
    at startup (internal/bootstrap/node.js:300:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:826:3)
[nodemon] app crashed - waiting for file changes before starting...

The app boots correctly, but as soon as any file changes, nodemon can't restart it. In the meantime, the app still continues to run in the background. If I do Ctrl+C, it quits, but there's no more process on port 3000, so killing it by port fuser -k 3000/tcp doesn't do anything.

I found that

  • it doesn't work with both yarn and npm, i.e. npm run dev produces the save error
  • it works when using require('./lib') in app.js instead of -r from the CLI
  • it works either way without express or any web server (because the port is not used)
  • same issue in Node 11.2.0, 11.1.0, and 10.13.0

I discovered this through esm when doing nodemon -r esm app, but later found out that it happens with any file. From that thread, the issue also seems to happen on MacOS as well. Tried rebooting, reinstalling Node, removing yarn.lock, then removing and re-installing node_modules, locking to older versions of nodemon, and express... I'm out of options here.

I scavenged many threads in this repo with this same error, but to no avail. I hope I'm posting in the right repo this time. Any help is appreciated, thanks!


P.S. Here's the dump with nodemon -r ./lib app --dump just in case.


Click to expand

> [email protected] dev /path/to/my/app
> nodemon -r ./lib app --dump

[nodemon] 1.18.6
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
--------------
node: v11.2.0
nodemon: 1.18.6
command: /home/alex/.nvm/versions/node/v11.2.0/bin/node /path/to/my/app/node_modules/.bin/nodemon -r ./lib app --dump
cwd: /path/to/my/app
OS: linux x64
--------------
{ run: false,
  system: { cwd: '/path/to/my/app' },
  required: false,
  dirs: [ '/path/to/my/app' ],
  timeout: 1000,
  options:
  { dump: true,
    ignore:
      [ '**/.git/**',
        '**/.nyc_output/**',
        '**/.sass-cache/**',
        '**/bower_components/**',
        '**/coverage/**',
        '**/node_modules/**',
        re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/ ],
    watch: [ '*.*', re: /.*\..*/ ],
    ignoreRoot:
      [ '**/.git/**',
        '**/.nyc_output/**',
        '**/.sass-cache/**',
        '**/bower_components/**',
        '**/coverage/**',
        '**/node_modules/**' ],
    restartable: 'rs',
    colours: true,
    execMap: { py: 'python', rb: 'ruby' },
    stdin: true,
    runOnChangeOnly: false,
    verbose: false,
    signal: 'SIGUSR2',
    stdout: true,
    watchOptions: {},
    execOptions:
      { script: 'index.js',
        exec: 'node',
        args: [ '-r', './lib', 'app' ],
        scriptPosition: 3,
        nodeArgs: undefined,
        execArgs: [],
        ext: 'js,mjs,json',
        env: {} },
    monitor:
      [ '*.*',
        '!**/.git/**',
        '!**/.nyc_output/**',
        '!**/.sass-cache/**',
        '!**/bower_components/**',
        '!**/coverage/**',
        '!**/node_modules/**' ] },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [],
  watchInterval: null,
  signal: 'SIGUSR2',
  command:
  { raw:
      { executable: 'node',
        args: [ '-r', './lib', 'app', 'index.js' ] },
    string: 'node -r ./lib app index.js' } }
--------------

Most helpful comment

Same behavior with lts/boron and lts/carbon. Tried with nodemon 1.18.x & 1.17.x.

Also happens when nodemon --exec.

Debian 4.18.10-2 x86_64

Strange.

Edit: --signal SIGTERM or --delay 1500ms do not change behavior.

Edit2: I am now using a bootstrap.js instead of the -r flag yet I still get the above error when restarting (simple edit). There is a db conn and an http server in the app. It feels like the server holds onto the db conn and thus nodemon can't terminate it.

All 28 comments

Same behavior with lts/boron and lts/carbon. Tried with nodemon 1.18.x & 1.17.x.

Also happens when nodemon --exec.

Debian 4.18.10-2 x86_64

Strange.

Edit: --signal SIGTERM or --delay 1500ms do not change behavior.

Edit2: I am now using a bootstrap.js instead of the -r flag yet I still get the above error when restarting (simple edit). There is a db conn and an http server in the app. It feels like the server holds onto the db conn and thus nodemon can't terminate it.

The problem is in pstree.remy. It was recently published to 1.1.2, which broke nodemon for many people (#1463, #1464, #1466). nodemon depends on it via pstree.remy "^1.1.0". Note the ^ symbol; it tells npm to pull the latest 1.x.x, in this case, 1.1.2, and not 1.1.0.

If you go to yarn.lock, change from pstree.remy "^1.1.0" to pstree.remy "1.1.0" (_no caret_), remove pstree.remy@^1.1.0: block altogether, and re-run yarn, it installs the older working version, and reload will be back to normal. The props go to @jordie23 for finding this out.

Okay, I'm finally able to replicate. It needs nodemon to be spawned inside of an npm run command.

The fix unfortunately did not resolve my problem with the EADDRINUSE on reload.

On first start, everything runs fine:

yarn run v1.12.3
$ nodemon -L --polling-interval 1000
[nodemon] 1.18.7
[nodemon] reading config ./nodemon.json
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 18 to restart
[nodemon] ignoring: ./dist/**/* ./secrets/**/* ./.git/**/* ./node_modules/**/* ./src/public/**/*
[nodemon] watching: /app/src/**/*
[nodemon] watching extensions: ts,js,json
[nodemon] starting `ts-node --files ./src/server.ts`
[nodemon] spawning
[nodemon] child pid: 30
[nodemon] watching 16 files
[info] Yellah Server listening on: 3095
[log] MongoDB: connected

After reloading a file (here src/server.ts) I get the EADDRINUSE error.

[nodemon] files triggering change check: src/server.ts
[nodemon] matched rule: /app/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/server.ts
2018-11-27T09:35:57.192753010Z 
[nodemon] starting `ts-node --files ./src/server.ts`
[nodemon] spawning
[nodemon] child pid: 44
[info] Yellah Server listening on: 3095
Error: listen EADDRINUSE :::3095
    at Server.setupListenHandle [as _listen2] (net.js:1286:14)
    at listenInCluster (net.js:1334:12)
    at Server.listen (net.js:1421:7)
    at Object.<anonymous> (/app/src/server.ts:30:12)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Module.m._compile (/app/node_modules/ts-node/src/index.ts:439:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/app/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at Object.<anonymous> (/app/node_modules/ts-node/src/bin.ts:157:12)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
[nodemon] app crashed - waiting for file changes before starting...

My nodemon.json:

{
  "verbose": true,
  "ignore": ["./dist/", "./secrets/", "./.git/", "./node_modules/", "./src/public/"],
  "watch": ["src"],
  "exec": "ts-node --files ./src/server.ts",
  "ext": "ts,js,json"
}

I use docker 18.09.0 on OSX running the node-alpine image v10.13.0. Also as you an see from the nodemon json I use the exec-flag to run ts-node. Node application does not do much but has a connection to mongodb if this matters.

-act

It probably does. My guess is that you're not closing off the connection to mongo cleanly so the sub process remains.

You'll need to provide a parred down example, ideally with little to zero dependencies to keep the example simple

I checked another node app that does not use any db connections and it still throws the error. Maybe it has something to do with ts-node or the polling options. I will investigate further why the process is not removed entirely.

yarn run v1.12.3
$ nodemon -L --polling-interval 1000
[nodemon] 1.18.7
[nodemon] reading config ./nodemon.json
[nodemon] to restart at any time, enter `rs`
[nodemon] or send SIGHUP to 18 to restart
[nodemon] ignoring: ./dist/**/* ./secrets/**/* ./.git/**/* ./node_modules/**/* ./src/public/**/*
[nodemon] watching: /app/src/**/*
[nodemon] watching extensions: ts,js,json
[nodemon] starting `ts-node --files ./src/server.ts`
[nodemon] spawning
[nodemon] child pid: 30
[nodemon] watching 14 files
[info] server listening on: 3112
[nodemon] files triggering change check: src/server.ts
[nodemon] matched rule: /app/src/**/*
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/server.ts
2018-11-27T10:22:35.895880142Z 
[nodemon] starting `ts-node --files ./src/server.ts`
[nodemon] spawning
[nodemon] child pid: 40
[info] server listening on: 3112
Error: listen EADDRINUSE :::3112
    at Server.setupListenHandle [as _listen2] (net.js:1286:14)
    at listenInCluster (net.js:1334:12)
    at Server.listen (net.js:1421:7)
    at Object.<anonymous> (/app/src/server.ts:21:12)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Module.m._compile (/app/node_modules/ts-node/src/index.ts:439:23)
    at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/app/node_modules/ts-node/src/index.ts:442:12)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
[nodemon] app crashed - waiting for file changes before starting...

Thank you.

On Tue, 27 Nov 2018, 10:38 Rocco Di Leo, notifications@github.com wrote:

I checked another node app that does not use any db connections and it
still throws the error. Maybe it has something to do with ts-node or the
polling options. I will investigate further why the process is not removed
entirely.

yarn run v1.12.3
$ nodemon -L --polling-interval 1000
[nodemon] 1.18.7
[nodemon] reading config ./nodemon.json
[nodemon] to restart at any time, enter rs
[nodemon] or send SIGHUP to 18 to restart
[nodemon] ignoring: ./dist//* ./secrets//* ./.git//* ./node_modules//* ./src/public//*
[nodemon] watching: /app/src/
/*
[nodemon] watching extensions: ts,js,json
[nodemon] starting ts-node --files ./src/server.ts
[nodemon] spawning
[nodemon] child pid: 30
[nodemon] watching 14 files
[info] server listening on: 3112

[nodemon] files triggering change check: src/server.ts
[nodemon] matched rule: /app/src/*/
[nodemon] changes after filters (before/after): 1/1
[nodemon] restarting due to changes...
[nodemon] src/server.ts
2018-11-27T10:22:35.895880142Z
[nodemon] starting ts-node --files ./src/server.ts
[nodemon] spawning
[nodemon] child pid: 40
[info] server listening on: 3112
Error: listen EADDRINUSE :::3112
at Server.setupListenHandle [as _listen2] (net.js:1286:14)
at listenInCluster (net.js:1334:12)
at Server.listen (net.js:1421:7)
at Object. (/app/src/server.ts:21:12)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Module.m._compile (/app/node_modules/ts-node/src/index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Object.require.extensions.(anonymous function) [as .ts] (/app/node_modules/ts-node/src/index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
[nodemon] app crashed - waiting for file changes before starting...

—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/remy/nodemon/issues/1463#issuecomment-442010737, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAA1hFwVTC01ZEUfHlUTEZO0oXNqP2h2ks5uzRYJgaJpZM4Yx9n-
.

@actraiser @remy

I can also confirm that upgrading nodemon to 1.18.7 didn't solve the issue.

I am getting by with using the kill-port trick shown in #1464. It is obviously a less than ideal solution.

p.s. The app I tried it on also uses a mongodb connection. Mongoose to be exact.

Edit: kill-port doesn't work. Use the bash script @actraiser supplied below. Here is the one I use;
lsof -i :<YOUR-PORT> | awk 'NR==2{print $2}' | xargs kill

Can you reduce the issue so we can replicate it, or can you debug and send a PR?

Just to add: the original issue raised is solved - I could replicate with the details provided. So this new issue, I suspect is related or similar, but needs bits to replicate

I stripped down my index.js to:

'use strict';
import express from 'express';

const app = express()
const port = 3000

app.listen(port)
console.log('Running on ' + port)

I have the following package setup:

  "main": "app/index.js",
  "scripts": {
    "start": "nodemon app/index.js --exec babel-node app/index.js "
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "cors": "^2.8.5",
    "express": "^4.16.4",
    "lodash": "^4.17.11",
    "moment": "^2.22.2",
    "morgan": "^1.9.1"
  },
  "devDependencies": {
    "@babel/cli": "^7.1.2",
    "@babel/core": "^7.1.2",
    "@babel/polyfill": "^7.0.0",
    "@babel/preset-env": "^7.1.0",
    "@babel/node": "^7.0.0",
    "nodemon": "1.18.4"
  }

I run npm start and get the following in the terminal

$ npm start

> [email protected] start /Users/ianbuss/sites/starcrusher/server
> nodemon app/index.js --exec babel-node app/index.js

[nodemon] 1.18.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node app/index.js app/index.js`
Running 3000
[nodemon] restarting due to changes...
[nodemon] starting `babel-node app/index.js app/index.js`
Running 3000
events.js:167
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3000
    at Server.setupListenHandle [as _listen2] (net.js:1334:14)
    at listenInCluster (net.js:1382:12)
    at Server.listen (net.js:1469:7)
    at Function.listen (/Users/ianbuss/sites/starcrusher/server/node_modules/express/lib/application.js:618:24)
    at Object.listen (/Users/ianbuss/sites/starcrusher/server/app/index.js:30:5)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Module._compile (/Users/ianbuss/sites/starcrusher/server/node_modules/pirates/lib/index.js:83:24)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.newLoader [as .js] (/Users/ianbuss/sites/starcrusher/server/node_modules/pirates/lib/index.js:88:7)
    at Module.load (internal/modules/cjs/loader.js:599:32)
Emitted 'error' event at:
    at emitErrorNT (net.js:1361:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)
    at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
    at Object.<anonymous> (/Users/ianbuss/sites/starcrusher/server/node_modules/@babel/node/lib/_babel-node.js:224:23)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
[nodemon] app crashed - waiting for file changes before starting...

Created a project with just express and nodemon and it works. Looks to be something with the execution flag; however, I'm not familiar enough with npm, nodemon, or babel to tinker with it entirely.

I checked what processes where actually involved when running nodemon in my docker container. On startup it looks like this, take note of pid 45+46. pid 45 is what nodemon reports as being the child pid.

/app # ps aux | grep node
    6 act     0:00 node /usr/local/bin/yarn run dev
   17 act     0:00 {node} /bin/sh /tmp/yarn--1543317198224-0.07979580787773166/node /app/node_modules/.bin/nodemon -L --polling-interval 1000
   18 act     0:00 /usr/local/bin/node /app/node_modules/.bin/nodemon -L --polling-interval 1000
   45 act     0:00 {node} /bin/sh /tmp/yarn--1543317198224-0.07979580787773166/node /app/node_modules/.bin/ts-node --files ./src/server.ts
   46 act     0:00 /usr/local/bin/node /app/node_modules/.bin/ts-node --files ./src/server.ts

When I change and save a file, process 45 is killed which is probably what nodemon does. However, Pid 46 is still left behind and i get the EADDRINUSE-error.

/app # ps aux | grep node
    6 act     0:00 node /usr/local/bin/yarn run dev
   17 act     0:00 {node} /bin/sh /tmp/yarn--1543317198224-0.07979580787773166/node /app/node_modules/.bin/nodemon -L --polling-interval 1000
   18 act     0:00 /usr/local/bin/node /app/node_modules/.bin/nodemon -L --polling-interval 1000
   46 act     0:00 /usr/local/bin/node /app/node_modules/.bin/ts-node --files ./src/server.ts

When I kill PID 46 in the docker container manually using 'kill -9 46', I can actually change a watched file and the app reloads on save as expected without throwing EADDRINUSE.

I am no expert on process handling on linux, so I actually don't even know why two pids are involved here. Maybe someone more proficient can shed some light on this? I tend to believe this is due to the exec-command usage.

Greets
-act

Can you replicate with Babel removed?

Can you reduce the issue so we can replicate it, or can you debug and send a PR?

I tried with vanilla http, basic express, and express+mongoose. First two work fine. I actually think mongoose is the culprit here.

I can't investigate further (at least today) because I have to power through something. Here is a hacky thing I had to do, though, might be related.

I'd have tried it with a couple more db drivers if I had the time. Please bring nodemon back @remy, I didn't realize how much I depend on it.

Edit: I also get one extra db connection (process) when nodemon tries to restart. I am guessing a fresh process is .fork'ed before terminating the old one? Old one refuses to be terminated.

In my case it's not a db-connection but the second not terminated ts-node process as described in https://github.com/remy/nodemon/issues/1463#issuecomment-442023737

My workaround now is this additional configuration entry in nodemon.json which uses an sh-command to identify the process and kills it. Installing the kill-all package as recommended above did not work for me.

  "events": {
    "restart": "ps -ef | grep '/usr/local/bin/node /app/node_modules/.bin/ts-node' | grep -v grep | awk '{print $1}' | xargs -r kill -9"
  }

Greets
-act

@remy

Tried the initial app with node-dev. Same thing happens. Again with node 8 & 10 lts.

Here is the dependencies for node-dev;

{
  dateformat: '~1.0.4-1.2.3',
  'dynamic-dedupe': '^0.2.0',
  filewatcher: '~3.0.0',
  minimist: '^1.1.3',
  'node-notifier': '^4.0.2',
  resolve: '^1.0.0' 
}

I don't see any commonality with nodemon. Node versions do not seem to matter, also. Maybe this issue is related to the new linux kernel? I think everyone uses it, nowadays.

@remy

Once we've bumped nodemon to 1.18.6 in the nodemon-webpack-plugin, our tests started failing due to the issue in this ticket. That meant we had to disable tests in order to publish the new version of the plugin.

I take it no test in this repo caught this issue.

I'm writing this to say that there are already tests for the plugin to would catch this issue. All the groundwork has already been done.

So maybe it is worth copying these across with slight modifications (you'll have to spawn nodemon rather than webpack)?

@Izhaki have you bumped to 1.18.7? That's the latest with these fixes in it?

Thankfully I've landed on this issue and bumped to 1.18.7 - I was already on course to spending days on this!

(On Monday eve we've bumped to 1.18.6 but had to disable the tests in order to publish; last night we've bumped to 1.18.7 and reinstated the tests).

Have a look at the tests for the plugin and let me know if you think porting them here is viable.

@remy I was unable to replicate without babel as a dependency. I realized somehow I was still on 1.18.4 updated to 1.18.7 and it resolved my experience.

@remy

This is a tricky, hard-to-reproduce bug.

The initial app (http & mongo) worked with nodemon for a couple hours. Then it started throwing the above error. I'm not sure how it got to that state.

While things were working, I fired up a vscode debugger that runs nodemon --inspect. I stopped the vscode debugger but it didn't terminate nodemon, and left a couple of node processes running. However, I killed them manually, and it was a while after that before I got the EADDRINUSE.

Also, when I hit the error, I had added a simple \n to the file. Adding another \n after that (expectedly) didn't work. However, when I restored the file to its original state before the error (delete the 2 \n's) nodemon was able to restart the script.

So, if I restore the script to its clean state, I can re-attach the port. Any code edits after that get the erroneous state.

I restarted my OS, and now everything seems to be working fine. I think clearing stray (node?) processes has something to do with it.

I will be mindful of what I was previously doing if I get the error again.

Edit: I can confirm that the vscode debugger is at least one of the reasons for this. It might be my launch.json has errors. The node processes it leaves behind, even if I kill them manually, cause nodemon to re-attach only to the state of the script vscode left it in. Here is my launch.json;

{
      "type": "node",
      "request": "launch",
      "name": "nodemon",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/nodemon",
      "runtimeArgs": ["--inspect"],
      "program": "${workspaceRoot}/bootstrap.js",
      "restart": true,
      "port": 9229,
      "protocol": "inspector",
}

Edit2: There seem to be some processed vscode leaves behind that I can't find. I just did killall node then restarted everything. Seems to solve the problem without requiring an OS restart.

Experiencing the same on 1.18.7.

nodemon --exec babel-node src

I have the same experiencing

yarn dev

{
  "name": "astoria",
  "version": "0.0.1",
  "description": "backend part of himself65 official website",
  "main": "src/index.js",
  "repository": "https://github.com/Himself65/Astoria.git",
  "author": "himself65",
  "license": "MIT",
  "scripts": {
    "lint": "eslint ./src/**/*.{js,ts}",
    "lint-fix": "lint --fix",
    "dev": "nodemon --exec babel-node src/index.js NODE_ENV=development ",
    "start": "cross-env pm2 start ecosystem.config.js --env production",
    "build": "babel src -d dist",
    "test": "node build/run-tests.js",
    "test:unix": "cross-env NODE_ENV=test jest",
    "test:win32": "cross-env NODE_ENV=test jest -i",
    "test:coverage": "yarn test --coverage"
  },
  "dependencies": {
    "axios": "^0.18.0",
    "koa": "^2.6.2",
    "koa-jwt": "^3.5.1",
    "koa-logger": "^3.2.0",
    "koa-router": "^7.4.0",
    "koa-static": "^5.0.0",
    "koa-unless": "^1.0.7",
    "koa2-connect-history-api-fallback": "^0.0.6",
    "mongoose": "^5.3.15",
    "pm2": "^3.2.2",
    "sequelize": "^4.41.2",
    "url": "^0.11.0"
  },
  "devDependencies": {
    "@babel/cli": "^7.2.0",
    "@babel/core": "^7.2.0",
    "@babel/node": "^7.2.0",
    "@babel/plugin-proposal-object-rest-spread": "^7.2.0",
    "@babel/plugin-transform-runtime": "^7.2.0",
    "@babel/preset-env": "^7.2.0",
    "@babel/runtime": "^7.2.0",
    "@types/jest": "^23.3.10",
    "@types/koa": "^2.0.47",
    "@types/node": "^10.12.12",
    "babel-core": "^7.0.0-bridge.0",
    "babel-eslint": "^10.0.1",
    "babel-jest": "^23.6.0",
    "cross-env": "^5.2.0",
    "eslint": "^5.9.0",
    "eslint-config-standard": "^12.0.0",
    "eslint-import-resolver-babel-module": "^4.0.0",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-node": "^8.0.0",
    "eslint-plugin-promise": "^4.0.1",
    "eslint-plugin-standard": "^4.0.0",
    "jest": "^23.6.0",
    "nodemon": "^1.18.7"
  }
}

@Himself65 you need to bump to [email protected]

cambie el port en y funciono

My case:

 "nodemon": "^1.19.1"
 "concurrently": "^4.1.0",

Command: export NODE_ENV=development && ./node_modules/.bin/concurrently "node --trace-deprecation ./scripts/start.js" "DEBUG=http ./node_modules/.bin/nodemon --watch mock-api ./mock-api/server.js"

I'm running into this issue too.

Ubuntu 18.04.2
nodemon ^1.19.1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mohammad-Quanit picture Mohammad-Quanit  Â·  5Comments

robboerman picture robboerman  Â·  3Comments

Autre31415 picture Autre31415  Â·  4Comments

jonerer picture jonerer  Â·  4Comments

binarykitchen picture binarykitchen  Â·  5Comments