1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| pkg [options] <input> Options:
-h, --help output usage information 帮助 -v, --version output pkg version pkg版本 -t, --targets comma-separated list of targets (see examples) 目标系统、node版本列表 -c, --config package.json or any json file with top-level config 配置json文件 --options bake v8 options into executable to run with them on node或v8运行时选项,例如 max-old-space-size= 参考 https://nodejs.org/api/cli.html https://www.nodeapp.cn/cli.html -o, --output output file name or template for several files 输出文件名称 --out-path path to save output one or more executables 输出文件目录 -d, --debug show more information during packaging process [off] 输出debug日志 非常有用,解决问题基本全靠它 -b, --build don't download prebuilt base binaries, build them 从源代码编译基本二进制文件,而非下载好的编译版本,当前系统需要满足编译要求 --public speed up and disclose the sources of top-level project 加快顶级项目来源公开 --public-packages force specified packages to be considered public 强制指定的包被认为是公共的 --no-bytecode skip bytecode generation and include source files as plain js 跳过字节码生成并将源文件包含为普通js --no-native-build skip native addons build 跳过本地插件的构建 --no-dict comma-separated list of packages names to ignore dictionaries. Use --no-dict * to disable all dictionaries 以逗号分隔的包名列表,以忽略字典。使用——no-dict *禁用所有字典 -C, --compress [default=None] compression algorithm = Brotli or GZip 压缩算法
Examples: 举例 – Makes executables for Linux, macOS and Windows $ pkg index.js – Takes package.json from cwd and follows 'bin' entry $ pkg . – Makes executable for particular target machine $ pkg -t node14-win-arm64 index.js – Makes executables for target machines of your choice $ pkg -t node12-linux,node14-linux,node14-win index.js – Bakes '--expose-gc' and '--max-heap-size=34' into executable $ pkg --options "expose-gc,max-heap-size=34" index.js – Consider packageA and packageB to be public $ pkg --public-packages "packageA,packageB" index.js – Consider all packages to be public $ pkg --public-packages "*" index.js – Bakes '--expose-gc' into executable $ pkg --options expose-gc index.js – reduce size of the data packed inside the executable with GZip $ pkg --compress GZip index.js
|