nodemon: Nodemon hangs if started without internet connection
- Versions: node@v16.18.1, linux@5.15.0-56-generic
nodemon -v: 2.0.20- Operating system/terminal environment (powershell, gitshell, etc): fish on gnome-terminal on ubuntu
- Using Docker? What image: no
- Command you ran:
npx nodemon server.js
Expected behaviour
When I run npx nodemon server.js while connected to the internet, the server starts up as expected, preceded by nodemon printing its info messages. When I run the same without an internet connection, I expect it to behave the same.
Actual behaviour
When starting nodemon without an internet connection, the program hangs indefinitely, without printing anything to the terminal. This happens even when just running nodemon --help.
Steps to reproduce
- Disconnect your internet
- Invoke nodemon
nodemon --dump:
{
run: false,
required: false,
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 a year ago
- Comments: 15 (6 by maintainers)
Finally got around to giving this a proper test. It’s actually just
npxthat is the issue.You get the same behaviour if you disconnect from the web and run any other
npx xxxcommand that can’t be loaded from a parent directory (which is whynpx nodemonworks when you have nodemon installed globally).Try the following (assuming you don’t have enhance globally):
It’s hang in the same way.
I suggest @davidhusz raise this (in a non-nodemon specific way) with npm 👍
I just tried out what @nejclovrencic mentioned and can confirm that the bug also only happens for me when nodemon is not installed globally. Interestingly, as long as it’s installed globally it works both when invoking it via
nodemonas well as vianpx nodemon.