This question already has an answer here:
这个问题在这里已有答案:
- How to make exe files from a node.js app? 17 answers
如何从node.js应用程序制作exe文件? 17个答案
I'm trying to find a way to use a command line nodejs application that I created on a computer without node.js installed. In other words how to package my application with node.js inside, in order to avoid the users to have node.js already installed.
我正在尝试找到一种方法来使用我在没有安装node.js的计算机上创建的命令行nodejs应用程序。换句话说,如何将我的应用程序与node.js打包在一起,以避免用户已经安装了node.js.
The tipical use case is: I run the application and the application works using the node core that is provide with the application (or the application checks if there is node.js installed, and if not it download and install it automatically).
典型用例是:我运行应用程序,应用程序使用随应用程序提供的节点核心(或应用程序检查是否安装了node.js,如果没有,则下载并自动安装)。
Do you have any idea?
你有什么主意吗?
4 个解决方案
#1
1
JXcore allows you to do that.
JXcore允许您这样做。
Once you have JXcore installed on windows (or unix systems), all you have to do is run:
一旦在Windows(或unix系统)上安装了JXcore,您只需运行:
jx package app.js "myAppName" -native
This will produce a .exe (or unix executable if the command was run on a unix system) file that you can distributed and can be executed without any external dependencies whatsoever (you don't even need JXcore nor Node.js on the system).
这将生成一个.exe(如果命令在unix系统上运行,则为unix可执行文件),您可以分发该文件,并且可以在没有任何外部依赖性的情况下执行(您甚至不需要系统上的JXcore或Node.js) 。
Here's the documentation on that functionality: http://jxcore.com/packaging-code-protection/#cat-74
以下是该功能的文档:http://jxcore.com/packaging-code-protection/#cat-74
(Duplicate of https://*.com/a/27551233/810830)
(重复https://*.com/a/27551233/810830)
#2
0
Checking the Node.js License, it appears that it is MIT licensed, so it's perfectly legal to do so.
检查Node.js许可证,它似乎是MIT许可的,所以这样做是完全合法的。
I'm assuming you're targeting Windows or Mac, since on Linux you could just release a package that depends on Node.js of a particular version, and provide a script to add one of the various free repositories for .deb
or .rpm
pre-compiled versions of Node.js.
我假设你的目标是Windows或Mac,因为在Linux上你可以发布一个依赖于特定版本的Node.js的包,并提供一个脚本来为.deb或.rpm添加各种免费存储库之一。 Node.js的预编译版本
You'll need to get the source for the version you're interested in and build it for your platform of choice. As I recall, the built executable can be run directly without being installed, but it assumes certain libraries are available on the $PATH
(OpenSSL being the one they're explicitly mentioning in the license as liked instead of statically compiled into the binary).
您需要获取您感兴趣的版本的源代码并为您选择的平台构建它。我记得,构建的可执行文件可以直接运行而无需安装,但它假定$ PATH上有某些库可用(OpenSSL是他们在许可证中明确提到的那个,而不是静态编译成二进制文件)。
Reading the Visual Studio build script, it looks like you'll need Python to be installed for Windows to build the .exe
. I suspect (but don't know for sure) that the executable is essentially stand-alone for Windows, so you can bundle your Javascript code with it and write a simple batch file to get it running on that platform. I have no idea how to make a Windows .msi
installer, but the vcbuild.bat file also includes the ability to generate one, so you could just piggyback on their code to do it.
阅读Visual Studio构建脚本,看起来您需要安装Python才能构建.exe。我怀疑(但不确定)可执行文件基本上是Windows独立的,因此您可以将Javascript代码与它捆绑在一起并编写一个简单的批处理文件,以使其在该平台上运行。我不知道如何制作Windows .msi安装程序,但vcbuild.bat文件还包括生成一个的能力,因此您可以依靠他们的代码来执行此操作。
#3
0
Python, Perl and Tcl all have utilities that will take a script and create an executible for a given platform. (I don't know about Ruby, PHP etc.) -- so far, no utility like this exists for nodejs, but I would be interested in one existing as well.
Python,Perl和Tcl都有实用程序,它们将获取脚本并为给定平台创建可执行文件。 (我不知道Ruby,PHP等) - 到目前为止,nodejs还没有这样的实用程序,但我也会对现有的实用程序感兴趣。
There is a build option in node to have it run a specified script on launch, so some of the plumbing is there.
节点中有一个构建选项,可以在启动时运行指定的脚本,因此有些管道存在。
#4
0
There are few but Node-webkit looks like the clear winner at the moment. A previous alternative appjs was deprecated, here is the related tweet:
现在很少有Node-webkit看起来像是明显的赢家。以前的替代appjs已被弃用,这是相关的推文:
AppJS is not maintained anymore as node-webkit (https://github.com/rogerwang/node-webkit …) fulfilled the purpose. Thanks everyone for supporting us:(
由于node-webkit(https://github.com/rogerwang/node-webkit ...)已达到目的,因此不再维护AppJS。谢谢大家支持我们:(
Have a look at the apps already written.
看看已编写的应用程序。
#1
1
JXcore allows you to do that.
JXcore允许您这样做。
Once you have JXcore installed on windows (or unix systems), all you have to do is run:
一旦在Windows(或unix系统)上安装了JXcore,您只需运行:
jx package app.js "myAppName" -native
This will produce a .exe (or unix executable if the command was run on a unix system) file that you can distributed and can be executed without any external dependencies whatsoever (you don't even need JXcore nor Node.js on the system).
这将生成一个.exe(如果命令在unix系统上运行,则为unix可执行文件),您可以分发该文件,并且可以在没有任何外部依赖性的情况下执行(您甚至不需要系统上的JXcore或Node.js) 。
Here's the documentation on that functionality: http://jxcore.com/packaging-code-protection/#cat-74
以下是该功能的文档:http://jxcore.com/packaging-code-protection/#cat-74
(Duplicate of https://*.com/a/27551233/810830)
(重复https://*.com/a/27551233/810830)
#2
0
Checking the Node.js License, it appears that it is MIT licensed, so it's perfectly legal to do so.
检查Node.js许可证,它似乎是MIT许可的,所以这样做是完全合法的。
I'm assuming you're targeting Windows or Mac, since on Linux you could just release a package that depends on Node.js of a particular version, and provide a script to add one of the various free repositories for .deb
or .rpm
pre-compiled versions of Node.js.
我假设你的目标是Windows或Mac,因为在Linux上你可以发布一个依赖于特定版本的Node.js的包,并提供一个脚本来为.deb或.rpm添加各种免费存储库之一。 Node.js的预编译版本
You'll need to get the source for the version you're interested in and build it for your platform of choice. As I recall, the built executable can be run directly without being installed, but it assumes certain libraries are available on the $PATH
(OpenSSL being the one they're explicitly mentioning in the license as liked instead of statically compiled into the binary).
您需要获取您感兴趣的版本的源代码并为您选择的平台构建它。我记得,构建的可执行文件可以直接运行而无需安装,但它假定$ PATH上有某些库可用(OpenSSL是他们在许可证中明确提到的那个,而不是静态编译成二进制文件)。
Reading the Visual Studio build script, it looks like you'll need Python to be installed for Windows to build the .exe
. I suspect (but don't know for sure) that the executable is essentially stand-alone for Windows, so you can bundle your Javascript code with it and write a simple batch file to get it running on that platform. I have no idea how to make a Windows .msi
installer, but the vcbuild.bat file also includes the ability to generate one, so you could just piggyback on their code to do it.
阅读Visual Studio构建脚本,看起来您需要安装Python才能构建.exe。我怀疑(但不确定)可执行文件基本上是Windows独立的,因此您可以将Javascript代码与它捆绑在一起并编写一个简单的批处理文件,以使其在该平台上运行。我不知道如何制作Windows .msi安装程序,但vcbuild.bat文件还包括生成一个的能力,因此您可以依靠他们的代码来执行此操作。
#3
0
Python, Perl and Tcl all have utilities that will take a script and create an executible for a given platform. (I don't know about Ruby, PHP etc.) -- so far, no utility like this exists for nodejs, but I would be interested in one existing as well.
Python,Perl和Tcl都有实用程序,它们将获取脚本并为给定平台创建可执行文件。 (我不知道Ruby,PHP等) - 到目前为止,nodejs还没有这样的实用程序,但我也会对现有的实用程序感兴趣。
There is a build option in node to have it run a specified script on launch, so some of the plumbing is there.
节点中有一个构建选项,可以在启动时运行指定的脚本,因此有些管道存在。
#4
0
There are few but Node-webkit looks like the clear winner at the moment. A previous alternative appjs was deprecated, here is the related tweet:
现在很少有Node-webkit看起来像是明显的赢家。以前的替代appjs已被弃用,这是相关的推文:
AppJS is not maintained anymore as node-webkit (https://github.com/rogerwang/node-webkit …) fulfilled the purpose. Thanks everyone for supporting us:(
由于node-webkit(https://github.com/rogerwang/node-webkit ...)已达到目的,因此不再维护AppJS。谢谢大家支持我们:(
Have a look at the apps already written.
看看已编写的应用程序。