[英]NodeJS pkg how to specify main function
Basically I was doing some testing with the npm package named pkg
This one基本上我正在用 npm package 命名
pkg
这个做一些测试
I was able to compile successfully and the program was running great if i were to run it through command prompt, but when i would just try double clicking the executable, i would get a command prompt window open for a split seconds and then close again, this is the code i tried testing it with如果我通过命令提示符运行它,我能够成功编译并且程序运行良好,但是当我尝试双击可执行文件时,我会得到一个命令提示符 window 打开几秒钟然后再次关闭,这是我尝试用它测试的代码
let prompt = require("prompt-sync")
async function run() {
let result = await a()
console.log(result)
let b = await prompt.query("input test ")
console.log(b)
}
run();
This all worked just fine when i ran the compiled app through command prompt, but doesnt work when i double click the app当我通过命令提示符运行编译的应用程序时,这一切都很好,但是当我双击应用程序时不起作用
What I've tried so far:到目前为止我已经尝试过:
Any help is appreciated任何帮助表示赞赏
Okay, so after a bit of testing i found i can do the following:好的,所以经过一些测试后,我发现我可以执行以下操作:
let i = 0; function run() { console.log("hi") } while (true) { if(i === 0) { run(); i++; } }
Like this it will just run the program once while still not just popping up for a split second and closing.像这样,它只会运行程序一次,而不会只是瞬间弹出并关闭。
This is not exactly what I wanted but this works the same way, which is good enough.这不完全是我想要的,但它的工作方式相同,这已经足够好了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.