如何使用 Node.js 创建独立的命令行应用程序 [英] How to create a stand alone command line application with Node.js

查看:36
本文介绍了如何使用 Node.js 创建独立的命令行应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方法来使用我在未安装 node.js 的计算机上创建的命令行 nodejs 应用程序.换句话说,如何将我的应用程序与 node.js 打包在一起,以避免用户已经安装了 node.js.

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,如果没有,它会自动下载并安装).

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).

你有什么想法吗?

推荐答案

JXcore 允许您这样做.

一旦您在 windows(或 unix 系统)上安装了 JXcore,您所要做的就是运行:

Once you have JXcore installed on windows (or unix systems), all you have to do is run:

jx package app.js "myAppName" -native

这将生成一个 .exe(或 unix 可执行文件,如果命令在 unix 系统上运行)文件,您可以分发该文件并且可以在没有任何外部依赖的情况下执行(您甚至不需要 JXcore 或 Node.js)系统).

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).

这是关于该功能的文档:http://jxcore.com/packaging-code-protection/#cat-74

Here's the documentation on that functionality: http://jxcore.com/packaging-code-protection/#cat-74

(重复的 https://stackoverflow.com/a/27551233/810830)

这篇关于如何使用 Node.js 创建独立的命令行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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