question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nodemon opens windows-kill.exe but doesn't restart process

See original GitHub issue

Versions

  • Versions: node@v12.2.0, win32@10.0.19043
  • nodemon -v:
$ npm view nodemon version
2.0.12
  • Operating system/terminal environment (powershell, gitshell, etc):
    • Powershell terminal
$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1023
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1023
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
  • VSCode IDE
    • Version: 1.58.2 (system setup) Commit: c3f126316369cd610563c75b1b1725e0679adfb3 Date: 2021-07-14T22:10:15.214Z Electron: 12.0.13 Chrome: 89.0.4389.128 Node.js: 14.16.0 V8: 8.9.255.25-electron.0 OS: Windows_NT x64 10.0.19043

Expected behaviour

Application would restart as normal, killing process and rerunning npm start which kicks off nodemon using nodemon.json config

Actual behaviour

Application starts as normal and I see the proper output in VSCode debug console. image

Changing the src/index.ts (uncommenting the code to add the “Hello World” endpoint) and saving the file does the following:

  • Prints [nodemon] restarting due to changes... to the VSCode debug window
  • Opens the windows-kill.exe window, minimized on my toolbar
  • Nothing else and doesn’t restart the application

The changes are not redeployed, and the only way to proceed is to kill the process manually. image

Steps to reproduce

I have attached this sample project here as the most basic application I could get to reproduce this issue.

Manual Steps

If you wish to do this from scratch, the steps I followed were:

  • Make empty, temporary directory
  • npm init -y
  • npm i -D typescript ts-node nodemon @types/node @hapi/hapi
  • npx tsc --init
  • Create nodemon.json
{
  "watch": ["src"],
  "ext": "ts",
  "exec": "node -r ts-node/register src/index.ts"
}
  • Update package.json start script
"scripts": {
  "start": "nodemon"
},
  • Create .vscode/launch.json
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Server",
            "type": "pwa-node",
            "outputCapture": "std",
            "request": "launch",
            "runtimeArgs": [
                "run-script",
                "start"
            ],
            "runtimeExecutable": "npm",
            "skipFiles": [
                "<node_internals>/**"
            ],
        },
    ]
}
"use strict";

const Hapi = require("@hapi/hapi");

const init = async () => {
  const server = Hapi.server({
    port: 3000,
    host: "localhost",
  });

  server.route({
      method: 'GET',
      path: '/',
      handler: (request, h) => {
          return 'Hello World!';
      }
  });

  await server.start();
  console.log("Server running on %s", server.info.uri);
};

process.on("unhandledRejection", (err) => {
  console.log(err);
  process.exit(1);
});

init();

{
  run: false,
  system: { cwd: 'c:\\OpenSesame\\tmp\\nodemon-example' },
  required: false,
  dirs: [ 'c:\\OpenSesame\\tmp\\nodemon-example\\src' ],
  timeout: 1000,
  options: {
    dump: true,
    watch: [ 'src', re: /src/ ],
    exec: 'node -r ts-node/register src/index.ts',
    ignore: [
      '**/.git/**',
      '**/.nyc_output/**',
      '**/.sass-cache/**',
      '**/bower_components/**',
      '**/coverage/**',
      '**/node_modules/**',
      re: /.*.*\/\.git\/.*.*|.*.*\/\.nyc_output\/.*.*|.*.*\/\.sass\-cache\/.*.*|.*.*\/bower_components\/.*.*|.*.*\/coverage\/.*.*|.*.*\/node_modules\/.*.*/
    ],
    monitor: [
      'c:\\OpenSesame\\tmp\\nodemon-example\\src/**/*',
      '!**/.git/**',
      '!**/.nyc_output/**',
      '!**/.sass-cache/**',
      '!**/bower_components/**',
      '!**/coverage/**',
      '!**/node_modules/**'
    ],
    ignoreRoot: [
      '**/.git/**',
      '**/.nyc_output/**',
      '**/.sass-cache/**',
      '**/bower_components/**',
      '**/coverage/**',
      '**/node_modules/**'
    ],
    restartable: 'rs',
    colours: true,
    execMap: { py: 'python', rb: 'ruby', ts: 'ts-node' },
    stdin: true,
    runOnChangeOnly: false,
    verbose: false,
    signal: 'SIGUSR2',
    stdout: true,
    watchOptions: {},
    execOptions: {
      script: null,
      exec: 'node -r ts-node/register src/index.ts',
      args: [],
      scriptPosition: null,
      nodeArgs: undefined,
      execArgs: [],
      ext: 'ts',
      env: {}
    }
  },
  load: [Function],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [ 'c:\\OpenSesame\\tmp\\nodemon-example\\nodemon.json' ],
  watchInterval: null,
  signal: 'SIGUSR2',
  command: {
    raw: { executable: 'node -r ts-node/register src/index.ts', args: [] },
    string: 'node -r ts-node/register src/index.ts'
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:23 (8 by maintainers)

github_iconTop GitHub Comments

7reactions
xsalazarcommented, Aug 10, 2021

@mchammer01 we were able to work around this issue by doing the following (you mentioned you’re not a developer, but maybe this will still be helpful)

  • If you have a nodemon.json config file, set "signal": "SIGKILL" or if you’re launching from CLI configuration, --signal SIGKILL should have the same result

(apologies for the hard ping) @remy I noticed there was no further patches recently after the release to bundle this locally (v0.2.8), so I want to try to understand why we could still be seeing this?

6reactions
remycommented, Aug 12, 2021

@mchammer01 if I can get the time today, I’ll push a debug version of nodemon to npm that switches to using this signal on Windows by default to see if we can nail this issue once and for all.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Port 3000 already in use but it actually isn't?
This single command line can kill the process running on given port. ... Example: Open the Windows Task Manager and see "node.exe" PID...
Read more >
nodemon - npm
nodemon is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the ...
Read more >
Debug Node.js Apps using Visual Studio Code
The Visual Studio Code editor includes Node.js debugging support. Set breakpoints, step-in, inspect variables and more.
Read more >
Nodemon creating Node process that can only be killed using ...
1 installed, and I am using Windows. The first time I execute the Nodemon app.js command, the server starts successfully. However, the program ......
Read more >
How to find and terminate a Windows Processes by Port
One error I was receiving when I would terminate and restart my app was that stating the specified port was already occupied! [nodemon]...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found