Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9234163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:43:31+00:00 2026-06-18T06:43:31+00:00

I am trying to use the child_process.spawn function. The syntax is child_process.spawn(command, args=[], [options])

  • 0

I am trying to use the child_process.spawn function. The syntax is

child_process.spawn(command, args=[], [options])

Whenever I include a space in any of the elements of the args array, the command simply emits the argument. Here is some code I used to test it

var spawn = require("child_process").spawn

console.log("This works");
var watcher = spawn("ls", ["-l"]);
watcher.stdout.on('data', function(data) {
    process.stdout.write(data.toString());
});

console.log("This does not work");
watcher = spawn("ls", ["-l", "/path with space in it"]);
watcher.stdout.on('data', function(data) {
    process.stdout.write(data.toString());
});

Is this a bug in node? Do I need to escape the space?

Edit: The above code is just an example. Here is the real code.
Maybe is has to do with the pipes?

watcher = spawn("supervisor", ["--extensions\ 'coffee|js|css|coffeekup'", "src/app.coffee"]);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:43:32+00:00Added an answer on June 18, 2026 at 6:43 am

    Don’t put spaces in args, just use another argument in the array

    var watcher = spawn("supervisor", [
      "--extensions",
      "'coffee|js|css|coffeekup'",
      "src/app.coffee"
    ]);
    

    A handy little shortcut I found if you want to get quick diagnostic output from your child processes is passing the {stdio: "inherit"} in options

    var watcher = spawn("supervisor", [
      "--extensions",
      "'coffee|js|css|coffeekup'",
      "src/app.coffee"
    ], {stdio: "inherit"});
    

    This way you can see whether everything is working properly right away.

    Lastly, depending on where supervisor is installed, you might want to consider using the full path.

    var watcher = spawn("/path/to/supervisor", ...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use html() function of jquery over the specific child like:
I'm trying to write a function, that would use native openssl to do some
I'm trying to execute a command line command(here: cat) from nodejs using the spawn
I'm trying to use the clone() function in C, and am uncertain of how
I am trying to create a function which takes a shell command as an
I'm trying to use Maven2 but my child projects cannot find the parent project.
I am trying to create Linq Expression that I can use to query child
i'm trying use facebook API to upload photo in my fan page. I downloaded
I am trying use gem tire to search in my application. I have tables
I was trying use a set of filter functions to run the appropriate routine,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.