[英]Node - Cross Plattform compilation - 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
文件復制那些文件,但沒有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.