如何从 node.js 应用程序制作 exe 文件? [英] How to make exe files from a node.js app?

查看:59
本文介绍了如何从 node.js 应用程序制作 exe 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个节点应用程序,运行如下:

I have a node app that I wrote, that I run as follows:

node.exe app.js inputArg

有什么方法可以将它自己打包成 .exe 吗?所以我可以做这样的事情吗?

Is there some way I can package this into a .exe by itself? So I can just do something like this?

App.exe inputArg

我有办法通过使用批处理文件来伪造它,所以我可以这样做:

I have some way of faking this by using a batch file, so I can do this:

App.bat inputArg

但这要求我在那个文件夹中有所有的依赖和节点,这并不理想.

But this requires that I have all the dependencies and node in that folder, which is not ideal.

推荐答案

有一些替代方案,包括免费的和商业的.我没有使用过它们中的任何一个,但理论上它们应该可以工作:

There a few alternatives, both free and commercial. I haven't used any of them but in theory they should work:

  • Iexpress (native windows tool)
  • Quick Batch File Compiler (commercial)
  • BoxedApp Packer
  • "Advanced" Batch To EXE Converter" (freeware)

大多数将要求您将批处理文件保留为主可执行文件,然后捆绑 node.exe 和您的脚本.

Most will require you to keep the batch file as main executable, and then bundle node.exe and your scripts.

根据您的脚本,您还可以选择将其移植到 JSDB,它支持 创建可执行文件的简便方法,只需向其附加资源即可.

Depending on your script, you also have the option to port it to JSDB, which supports an easy way to create executables by simply appending resources to it.

第三个准解决方案是将节点保存在 C:utils 之类的地方,并将此文件夹添加到您的 PATH 环境变量中.然后你可以在那个目录中创建 .bat 文件来运行 node + 你喜欢的脚本——我用这种方式在 windows 上使用了 coffeescript 的 coffee .可以使用批处理文件、vb 脚本或安装程序自动执行此设置.

A third quasi-solution is to keep node somewhere like C:utils and add this folder to your PATH environment variable. Then you can create .bat files in that dir that run node + your preferred scripts - I got coffeescript's coffee working on windows this way. This setup can be automated with a batch file, vb script or installer.

这篇关于如何从 node.js 应用程序制作 exe 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆