我使用commander.js
Node.js 平台构建了简单的命令行应用程序。现在我想把它编译成简单的exe
文件,我可以直接执行。
意味着我想要完整的应用程序的单个可执行文件
这是我的应用程序结构
APP_ROOT
| - package.json
| - node_modules
| - node_modules/.bin/myapp.bat
| - node_modules/myapp/bin/myapp
| - node_modules/myapp/bin/myapp-action1
| - node_modules/myapp/bin/myapp-action2
谢谢
pkg
使用安装模块npm i -g pkg
package.json
文件json
{
"name": "my-app-exe",
"version": "1.0.0",
"description": "Myapp-Cli tool as executable",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"myapp",
"cli",
"exe"
],
"author": "Shisht",
"license": "MIT",
"devDependencies": {
"myapp": "1.0.0"
},
"bin": "node_modules/myapp-cli/bin/cli",
"pkg": {
"assets": "node_modules/**/*"
},
"help": "pkg . --target host --output myapp-1.0.0-x64.exe --debug"
}
myapp
到myapp.exe
pkg . --target host --output myapp-1.0.0-x64.exe --debug
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句