跳至主要内容

如何使用 `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

就这样!