nodemon -v: 2.0.4
node -v: v14.8.0
OS: 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:
and:
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!
nodemon -v:2.0.4node -v:v14.8.0OS: Windows 10, Powershell, macOSI have a quick question that has perplexed me since I started using nodemon. Here's the relevant section from my package.json:
If I execute
nodemon .\src\server.js first secondthenconsole.log(process.argv)looks like:However, if I want to take advantage of nodemon's ability to automatically run the file associated with the
mainproperty of mypackage.jsonfile, and I executenodemon first second, thenconsole.log(process.argv)looks like:The first argument gets eaten.
Expected behaviour
I expect nodemon to determine that
firstisn't a Node application, so it should load the file associated with themainproperty of mypackage.jsonfile, and then pass myfirstandsecondarguments to it. I expectconsole.log(process.argv)to look like: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
mainproperty of mypackage.jsonfile appears as the second argument.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:
and:
so I can easily switch environments. I don't want to have to type in my main
.\src\server.jsevery time like this:Thanks!