node项目引用 node-canvas库后使用 pkg 打包出错问题

打包后运行exe程序 出现 

Error: The specified module could not be found.

修改项目 package.json 文件 

 1 "pkg": {
 2     "scripts": "*.js",
 3     "assets": [ 9       "node_modules/canvas/**/*"
10     ]
11   }

增加  "node_modules/canvas/**/*" 后使用命令 pkg -c package.json -t win index.js  重新打包

参考:https://github.com/vercel/pkg/issues/1714

posted @ 2025-01-15 09:46  西呱  阅读(97)  评论(0)    收藏  举报