简体   繁体   English

运行节点fileName.js命令后如何返回终端执行?

[英]How to return to terminal execution after running node fileName.js command?

I have a shell script as : 我有一个shell脚本:

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

my fileName.js : 我的fileName.js:

console.log("script executed");

Now after running node fileName.js command, the terminal is not executing commands after it ie echo "done"; exit 0; 现在,在运行node fileName.js命令之后,终端将不执行命令,即echo "done"; exit 0; echo "done"; exit 0;

So How can I return the control to terminal after executing node js file. 那么执行节点js文件后如何将控件返回到终端。

It works fine: 它工作正常:

a.js : a.js:

console.log("from node")

a.sh : a.sh:

#/bin/bash

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

output : bash a.sh 输出:bash a.sh

 from node
 from bash

You can try to add a process.exit(0) at the end of your node filename 您可以尝试在节点文件名的末尾添加process.exit(0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我输入终端命令“$ node fileName.js”时,concole 会抛出“SyntaxError: Unexpected token &#39;&lt;&#39;”错误 - When I enter the terminal command "$ node fileName.js" the concole throws out a "SyntaxError: Unexpected token '<'" error 在Docker容器中运行命令&#39;node filename.js&#39; - Run command 'node filename.js' inside a Docker container 如何在Electron中触发节点filename.js文件? - How to trigger node filename.js file in Electron? “node filename.js”在 vs 代码中不起作用 - “node filename.js” is not working in vs code Node.js 文件在正确执行后阻塞终端 - Node.js file blocks terminal after correct execution jscs 错误:validateLineBreaks:filename.js 处的换行符无效 - jscs error : validateLineBreaks: Invalid line break at filename.js 如何在没有终端命令的情况下运行节点 js 应用程序 - How to run node js application without terminal command 如何检查node.js脚本是否在终端或Web上运行? - How to check that node.js script is running on terminal or web? JS文件不在终端中与Node.js一起运行 - JS file not running with Node.js in terminal js 文件应该有什么名称,带有奇怪结尾的 url 引导:“.../filename.js?crc=6»? - What names should js files have, to which urls with a strange ending lead: ".../filename.js?crc=6»?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM