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 does not restart server, stuck on ---> [nodemon] restarting due to changes...

See original GitHub issue
  • Versions:
  • nodemon -v:2.0.15
  • Operating system/terminal environment (powershell, gitshell, etc): node@v16.13.0, win32@10.0.19043 / Git Bash
  • Using Docker? What image: No
  • Command you ran: npm start

Expected behaviour

Expected behavior is nodemon restarting the server after saving changes in the js/json files.

server.js file

const http = require('http');

const server = http.createServer((req, res) => {
  res.setHeader('Content-type', 'text/plain');
  res.write('Hello');
  res.end();
});

const PORT = 3000

server.listen(PORT, () => console.log(`Server is running on port ${PORT}`));

package.json

{
  "name": "nodejs",
  "version": "1.0.0",
  "description": "learn HTTP",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "nodemon server.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/JoeyFlaum/Node.js.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/JoeyFlaum/Node.js/issues"
  },
  "homepage": "https://github.com/JoeyFlaum/Node.js#readme",
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}

Actual behaviour

$ npm start

> nodejs@1.0.0 start
> nodemon server.js

[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
Server is running on port 3000
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...
[nodemon] restarting due to changes...

Steps to reproduce

  1. Start the server with npm start command.

  2. save either the package.json file or server.js file

  3. nodemon does not restart the server.


If applicable, please append the --dump flag on your command and include the output here ensuring to remove any sensitive/personal details or tokens.

> nodejs@1.0.0 start
> nodemon --dump server.js

[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
--------------
node: v16.13.0
nodemon: 2.0.15
command: C:\Program Files\nodejs\node.exe D:\Joey\WebDev\NodeJs\node_modules\nodemon\bin\nodemon.js --dump server.js   
cwd: D:\Joey\WebDev\NodeJs
OS: win32 x64
--------------
{
  run: false,
  system: { cwd: 'D:\\Joey\\WebDev\\NodeJs' },
  required: false,
  dirs: [ 'D:\\Joey\\WebDev\\NodeJs' ],
  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: /.*\..*/ ],
    monitor: [
      '*.*',
      '!**/.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: 'server.js',
      exec: 'node',
      args: [],
      scriptPosition: 0,
      nodeArgs: undefined,
      execArgs: [],
      ext: 'js,mjs,json',
      env: {}
    }
  },
  load: [Function (anonymous)],
  reset: [Function: reset],
  lastStarted: 0,
  loaded: [],
  watchInterval: null,
  signal: 'SIGUSR2',
  command: {
    raw: { executable: 'node', args: [ 'server.js' ] },
    string: 'node server.js'
  }
}
--------------

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zorridgecommented, Feb 2, 2022

I added the variables below to Path in system variables and it fixed the problem for me

C:\Windows; C:\Windows\system32; C:\Windows\System32\Wbem

1reaction
JoeyFlaumcommented, Jan 31, 2022

Is this issue similar/the same as https://github.com/remy/nodemon/issues/1971 ?

Are you guys using Git Bash as a terminal under VSCode? That might seem to be the common issue… it’s a Unix shell emulated on Windows… so not native functionality AFAIK. Try switching the terminal to CMD or PowerShell in VSCode, if you’re on Windows.

I tried PowerShell and CMD. Does the same thing…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nodemon stuck at "restarting due to changes..." and won't ...
First thing first, a proper restart-and-transpile process (since it's built using ES6 modules syntax). This is my folder structure: - src |- ...
Read more >
Nodemon stuck at "[nodemon] restarting due to changes" #1915
Try running nodemon version 2.0.7. It fixed my problem.
Read more >
nodemon is not restarting due to changes - Treehouse
I install nodemon <npm install -g nodemon>, I get the console message that all is going ok but when I change something in...
Read more >
nodemon not restarting Code Example
how to restart nodemon. ... nodemon is not working only just showing [nodemon] restarting due to changes... ... Which command will you run...
Read more >
Automatically Restart Node Apps on File Change with nodemon
Nodemon allows you to automate the process of restarting Node applications when you make changes to the underlying files. This isn't an issue ......
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