-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
nodemon .\src\server.js first second vs nodemon first second help... #1758
Description
nodemon -v:2.0.4node -v:v14.8.0OS: Windows 10, Powershell, macOS
I have a quick question that has perplexed me since I started using nodemon. Here's the relevant section from my package.json:
"main": "./src/server.js",
"scripts": {
"start": "node src/server.js"
}If I execute nodemon .\src\server.js first second then console.log(process.argv) looks like:
[
'C:\\Program Files\\nodejs\\node.exe',
'C:\\Users\\brian\\Code\\server\\src\\server.js',
'first',
'second'
]
However, if I want to take advantage of nodemon's ability to automatically run the file associated with the main property of my package.json file, and I execute nodemon first second, then console.log(process.argv) looks like:
[
'C:\\Program Files\\nodejs\\node.exe',
'C:\\Users\\brian\\Code\\server\\src\\server.js',
'second',
'./src/server.js'
]
The first argument gets eaten.
Expected behaviour
I expect nodemon to determine that first isn't a Node application, so it should load the file associated with the main property of my package.json file, and then pass my first and second arguments to it. I expect console.log(process.argv) to look like:
[
'C:\\Program Files\\nodejs\\node.exe',
'C:\\Users\\brian\\Code\\server\\src\\server.js',
'first',
'second'
]
Actual behaviour
My arguments are jumbled up. My second argument appears as the first argument, my first argument doesn't appear at all, and my file associated with the main property of my package.json file appears as the second argument.
[
'C:\\Program Files\\nodejs\\node.exe',
'C:\\Users\\brian\\Code\\server\\src\\server.js',
'second',
'./src/server.js'
]
Steps to reproduce
Show above.
nodemon has been around forever and is wonderful, so I assume that I'm being an idiot and there's just something I don't understand. I want the ease of being able to enter commands like:
nodemon dev
and:
nodemon dev-test
so I can easily switch environments. I don't want to have to type in my main .\src\server.js every time like this:
nodemon .\src\server.js first second
Thanks!