pkg打包nodejs软件报错Error! AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:解决办法

问题描述:

尝试使用pkg打包nodejs软件时,报错如下图所示

问题原因:

这是因为缓存里缺少对应的二进制文件fetched-v18.5.0-win-x64,我们需要手动下载该文件,并存入相应的缓存目录即可。

解决办法:

1.前往官网下载所需文件

https://github.com/vercel/pkg-fetch/releases

确认好版本,如下图,我的是 v3.4。名称为 node-v18.5.0-win-x64,那么我要在 v3.4 的目录下下载我们的对应文件 node-v18.5.0-win-x64

2.下载好后,将文件名改为 fetched-v18.5.0-win-x64
3.将文件放入当前用户的缓存目录 .pkg-cache 中

   默认目录一般为 C:\Users\你的用户名\.pkg-cache

   在当前 .pkg-cache 文件夹中创建 v3.4 文件夹,并将 fetched-v18.5.0-win-x64 文件放入其中

   

     

4.重新打包即可运行!
C:\Users\admin\Desktop\nature>pkg . --target node18-win-x64 --output 自然算法.exe > pkg@5.8.1 > Fetching base Node.js binaries to PKG_CACHE_PATH fetched-v18.5.0-win-x64 [ ] 0%> Not found in remote cache: {"tag":"v3.4","name":"node-v18.5.0-win-x64"} > Building base binary from source: built-v18.5.0-win-x64 > Fetching Node.js source archive from nodejs.org... > Error! AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value: (!this.bar) at Log.enableProgress (C:\Users\admin\AppData\Roaming\npm\node_modules\pkg\node_modules\pkg-fetch\lib-es5\log.js:64:30) at C:\Users\admin\AppData\Roaming\npm\node_modules\pkg\node_modules\pkg-fetch\lib-es5\utils.js:58:31 at step (C:\Users\admin\AppData\Roaming\npm\node_modules\pkg\node_modules\pkg-fetch\lib-es5\utils.js:33:23) at Object.next (C:\Users\admin\AppData\Roaming\npm\node_modules\pkg\node_modules\pkg-fetch\lib-es5\utils.js:14:53) at C:\Users\admin\AppData\Roaming\npm\node_modules\pkg\node_modules\pkg-fetch\lib-es5\utils.js:8:71 at new Promise (<anonymous>) at __awaiter (C:\Users\admin\AppData\Roaming\npm\node_modules\pkg\node_modules\pkg-fetch\lib-es5\utils.js:4:12) at downloadUrl (C:\Users\admin\AppData\Roaming\npm\node_modules\pkg\node_modules\pkg-fetch\lib-es5\utils.js:53:12) at C:\Users\admin\AppData\Roaming\npm\node_modules\pkg\node_modules\pkg-fetch\lib-es5\build.js:142:66 at step (C:\Users\admin\AppData\Roaming\npm\node_modules\pkg\node_modules\pkg-fetch\lib-es5\build.js:44:23) C:\Users\admin\Desktop\nature>
最新发布
11-29
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值