javascript - 节点 - 跨平台编译 - PKG
问题描述
我目前正在尝试使用 pkg 为 macos 编译节点应用程序:
首先我的设置:
macos 10.14.5 (Mojave)
node -v => v11.4.0
npm -v => 6.4.1
pkg -v => 4.4.0
我的第一次尝试:
pkg index.js -t node11-mac-x64 --output dist/app-mac
结果:
> pkg@4.4.0
> Error! No available node version satisfies 'node11'
这就是为什么我切换到:
pkg index.js -t node10-mac-x64 --output dist/app-mac
结果:
> pkg@4.4.0
> Warning
Cannot include addon %1 into executable.
The addon must be distributed with executable as %2.
node_modules/sha3/build/Release/sha3.node
path-to-executable/sha3.node
> Warning
Cannot include addon %1 into executable.
The addon must be distributed with executable as %2.
node_modules/websocket/build/Release/bufferutil.node
path-to-executable/bufferutil.node
> Warning
Cannot include addon %1 into executable.
The addon must be distributed with executable as %2.
node_modules/websocket/build/Release/validation.node
path-to-executable/validation.node
> Warning
Failed to make bytecode node10-x64 for file /snapshot/app/node_modules/brotli/build/encode.js
但是已经生成了可执行文件,所以我尝试运行它:
./app-mac
这导致了彻底的灾难:
pkg/prelude/bootstrap.js:1185
throw error;
^
Error: File '/**/app/node_modules/linebreak/src/classes.trie' was not included into executable at compilation stage. Please recompile adding it as asset or script.
at error_ENOENT (pkg/prelude/bootstrap.js:429:17)
at readFileFromSnapshot (pkg/prelude/bootstrap.js:657:29)
at Object.fs.readFileSync (pkg/prelude/bootstrap.js:700:18)
at Object.<anonymous> (/snapshot/app/node_modules/linebreak/src/linebreaker.js:15:32)
at Object.<anonymous> (/snapshot/app/node_modules/linebreak/src/linebreaker.js:161:4)
at Module._compile (pkg/prelude/bootstrap.js:1261:22)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:710:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
我已经阅读了 github 上与pkg相关的每一个问题,并尝试了各种配置,但没有一个有帮助......
有人可以帮忙吗?试图解决这个问题好几天了..
谢谢和问候!
我没有办法打包我的应用程序吗?
更新:在 github 他们说,我必须在构建过程中包含 .node 文件......但我该怎么做呢?
解决方案
我在使用pkg
. 但我认为您应该将其更改node10-mac-x64
为node14-mac-x64
. 这在 Windows 上对我有用。
而你所说的获取.node
文件,这仍然是一个大问题。我试图用我的.exe
文件复制那些,但它没有用。
推荐阅读
- tfs - 如何限制在 TFS 中为用户获取更改?
- sql - 将日期 24-NOV-49 转换为 yyyy-mm-dd 格式
- list - 列表总是返回单个元素
- android - DryIoc 容器异常仅在带有 Prism Android 应用的 XF 的 RELEASE 模式下
- ruby-on-rails - 无需注册即可识别用户的强大方法?
- c# - 如何在 Windows 7 上以编程方式读取另一个应用程序(未安装)的按钮操作
- c++ - 有效地将堆栈对象(由函数的值返回)分配给堆?
- r - R:根据其他列分类的变量的每日总和
- javascript - 无法在 beforeunload 事件上重置寡妇
- python - 在scrapy Request中放置python请求的数据属性的位置