Skip to content

How to configure nodemon.json to run node with arguments which contains space  #1823

@chucklu

Description

@chucklu
  • nodemon -v: 2.0.6
  • node -v: v12.18.0
  • Operating system/terminal environment: win10/cmd.exe
  • Command you ran:

Configuration in nodemon.json

  "events": {
	"exit": "node printdate.js \"cleanly exited\""
  }

Expected behaviour

I test the node command node printdate.js "cleanly exited" successfully with cmd.exe, and the output is

cleanly exited at 2021-01-06 17:32:42 408ms UTC+8

The parameters were

[
  'node.exe',
  'printdate.js',
  'cleanly exited'
]

Actual behaviour

'display at 2021-01-06 17:32:42 408ms UTC+8
The parameter generated by nodemon were

[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\workspace\\Edenred\\UK\\Connect_Incentive_Frontend\\vueSrc\\printdate.js',
  '"cleanly',
  'exited"'
]

What happened here? why the last parameter was divided into two parts?

Steps to reproduce

The content of printdate.js is as following

//console.log(process.argv);
var myArgs = process.argv.slice(2);
//console.log('myArgs: ', myArgs);

const dateTime = require('date-time');
var currentTime = dateTime({local: true, showTimeZone: true, showMilliseconds: true});
console.log(`${myArgs[0]} at ${currentTime}`)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions