我想将nodeJS编译成二进制,类似于C/C++。
编译
$NodeCompile -ofast Node.js -o executable
(如果我不能进行编译器设置也可以)
运行它
$./executable
使用Bun解决同样的问题。我在 package.json 中的脚本中添加了一个条目,如下所示:
"scripts": {
"compile": "bun build src/main.ts --compile --outfile out"
我现在像
bun run compile
一样运行它,我可以像./out
一样使用输出文件