nodemon: nodemon does not restart server, stuck on ---> [nodemon] restarting due to changes...
- 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
-
Start the server with
npm startcommand. -
save either the package.json file or server.js file
-
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'
}
}
--------------
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (3 by maintainers)
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\WbemI tried PowerShell and CMD. Does the same thing…