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 8950807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:31:11+00:00 2026-06-15T13:31:11+00:00

Possible Duplicate: node.js execute system command synchronously I wish to synchronously execute a node.js

  • 0

Possible Duplicate:
node.js execute system command synchronously

I wish to synchronously execute a node.js file from another node.js file. This is what I have but its async.

    var spawn = spawn('node', ['./file.js']);
    spawn.stdout.on('data',function(data){});
  • 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-15T13:31:12+00:00Added an answer on June 15, 2026 at 1:31 pm

    From your comments under the question, it sounds like you don’t want it to be synchronous, and that you don’t care about its output.

    If you just want to fire the other process and forget, without watching it or caring about when it ends, what you’re already using (spawn) does that.

    If you want to truly fire-and-forget, you’ll want to specify the detached option, so that the child process doesn’t get killed when your process terminates. From the docs:

    If the detached option is set, the child process will be made the leader of a new process group. This makes it possible for the child to continue running after the parent exits.

    Looking further down, apparently you have to unref it as well:

    By default, the parent will wait for the detached child to exit. To prevent the parent from waiting for a given child, use the child.unref() method, and the parent’s event loop will not include the child in its reference count.

    And apparently deal with stdio:

    When using the detached option to start a long-running process, the process will not stay running in the background unless it is provided with a stdio configuration that is not connected to the parent. If the parent’s stdio is inherited, the child will remain attached to the controlling terminal.

    So:

    spawn('node', ['./file.js'], {
        detached: true,
        stdio: [ 'ignore', 'ignore', 'ignore' ]
    }).unref();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Check synchronously if file/directory exists in Node.js For example, i have a
Possible Duplicate: A simple program to CRUD node and node values of xml file
Possible Duplicate: Closure library dom node from html text in jQuery you can create
Possible Duplicate: Parsing text in C Say I have written to a text file
Possible Duplicate: How to extract a node attribute from XML using PHP's DOM Parser
Possible Duplicate: Find values under one node in XML Sample XML File: <Book> <Page
Possible Duplicate: Copying one structure to another struct node { int n; struct classifier
Possible Duplicate: A simple program to CRUD node and node values of xml file
Possible Duplicate: A simple program to CRUD node and node values of xml file
Possible Duplicate: Nested type problem Let's say I have this code: public class Tree

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.