所以我要跑
tsc --build tsconfig.json
将tsconfig文件放在这个帖子的底部。然后我把密码打包-
pkg .\dist\server.js --output MyAppExe --targets node16-win-x64 --debug --public -
当我运行MyAppExe时,我会看到以下错误:
Failed to send request to zmqLayer TypeError: zmq.Context is not a constructor
at defaultContext (C:\snapshot\backend\node_modules\zeromq\lib\index.js:183:9)
at new <anonymous> (C:\snapshot\backend\node_modules\zeromq\lib\index.js:299:37)
at Function.<anonymous> (C:\snapshot\backend\node_modules\zeromq\lib\index.js:751:14)
我还看到了其他几个TS错误,比如"TypeError: zmq.zmqVersion不是函数“--但我不知道为什么。在下面的配置中,我应该将ts设置为忽略js和node_module文件。零q就是JS。
而pkg把js变成了exe...so,我不知道哪里出了问题。
tsconfig.json:
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es6",
"jsx": "react",
"allowJs": true,
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"suppressImplicitAnyIndexErrors": true,
"checkJs": false
},
"ts-node": {
"esm": true
},
"lib": ["esnext"],
"paths": [
"global.d.ts"
],
"include": ["./src", "./server.ts"],
"exclude": [
"node_modules",
"./node_modules",
"./node_modules/*",
"./node_modules/@types/node/index.d.ts",]
}
发布于 2022-10-24 12:23:04
编辑:我发现下面的解决方案仍然没有解决所有的问题。上面的线还在上面。通过手动编辑文件,我解决了这个和其他类型记录错误。似乎起了作用,但应该有更好的方法来做到这一点。
由于某种原因,pkg没有找到预构建的二进制文件。它在寻找
node.abi88.node.win.v16.16.0
当文件命名为
node.abi88.node
当我在pgk,producer.js第118行中放置一个producer.js时,发现了这一点。
console.log(nativeFile);
当我更改文件名时,一些问题消失了。现在只剩下两个..。
https://stackoverflow.com/questions/74143526
复制相似问题