跳至主要內容

如何使用 pkg

用戶端檔案並未自動包含為資產,您需要手動指定它們

index.js

const { Server } = require("socket.io");

const io = new Server();

io.on("connection", (socket) => {
// ...
});

io.listen(3000);
注意

目前不支援 ES 模組。更多資訊請參閱:https://github.com/vercel/pkg/issues/1291

pkg.json

{
"assets": "node_modules/socket.io/client-dist/*.js"
}

然後執行

$ pkg -c pkg.json -t node14-linux index.js

瞧!