12

Right now I have a nodeJS script that sets up a database for me. Whenever I run it in my command line, I need to ctrl-C to exit the script. I'm assuming that there is some kind of command within nodeJS to have it exit on its own when it's done, but I can't seem to find any such command by doing searches on the interwebz. Does anybody happen to know if this is possible, and if so, what the command is?

2 Answers 2

18

you can exit the script by calling process.exit() (see http://nodejs.org/docs/v0.5.4/api/process.html#process.exit)

Sign up to request clarification or add additional context in comments.

2 Comments

thanks! I feel stupid now. I actually looked at that page, and saw the very first entry was "Event: 'exit'" and totally not what I wanted, and just assumed that there wouldn't be anything else on that page related to exit. D'oh!
Should it be return process.exit(); or will it end the script execution even without returning?
3

you should be using process.exit(). You can pass any status also which will be displayed on the console log.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.