【问题标题】:How to return to terminal execution after running node fileName.js command?运行 node fileName.js 命令后如何返回终端执行?
【发布时间】:2017-11-27 14:02:22
【问题描述】:

我有一个 shell 脚本:

node fileName.js
echo "done";
exit 0;

我的文件名.js:

console.log("script executed");

现在运行node fileName.js 命令后,终端不执行它之后的命令,即echo "done"; exit 0;

那么如何在执行节点js文件后将控件返回到终端。

【问题讨论】:

  • node fileName.js 根本不运行你的 shell 脚本。

标签: javascript node.js shell command-line


【解决方案1】:

效果很好:

a.js:

console.log("from node")

a.sh:

#/bin/bash

node a.js
echo "from bash";
exit 0;

输出: bash a.sh

 from node
 from bash

您可以尝试在节点文件名的末尾添加一个 process.exit(0)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-08
    • 2019-12-22
    • 2015-04-02
    • 2016-04-05
    • 2017-08-18
    • 2015-05-27
    • 2022-01-12
    • 1970-01-01
    相关资源
    最近更新 更多