pkg

简介: pkg

使用

首选需要全局安装:

$ npm i -g pkg点击复制复制失败已复制


接下来打包就很容易了:

$  pkg .\dist\main.js -o start.exe点击复制复制失败已复制


生成出来的 start.exe 文件双击就能运行了。


Note

测试基于 nestjs 项目,打包时间会比较长,因为 node 是单线程的嘛,并且会遇到网络问题,请往下看。


踩坑

PKG_CACHE_PATH

因为 pkg 的原理是将 node 也打包进去,所以在执行打包命令的时候会先去获取 node ,我没有找到类似于设置的地方,不能指定其获取的地址,所以就在打包的时候开了 VPN ,让其能够先下载下来。


也可以在本地环境变量中设置 PKG_CACHE_PAT H地址,并且将资源预先拷贝进去,本人未测试,网上倒是有很多文章这样做的,例如:https://blog.51cto.com/livestreaming/2600395

目录
相关文章
【npm】npm install <folder>和 npm install <folder> --install-links 的区别
【npm】npm install <folder>和 npm install <folder> --install-links 的区别
137 0
解决ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accuratel
解决ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accuratel
627 0
解决ERROR: Cannot uninstall ‘PyYAML‘. It is a distutils installed project and thus we cannot accuratel
解决ERROR: Cannot uninstall ‘llvmlite‘. It is a distutils installed project and thus we cannot accurat
解决ERROR: Cannot uninstall ‘llvmlite‘. It is a distutils installed project and thus we cannot accurat
1041 0
解决ERROR: Cannot uninstall ‘llvmlite‘. It is a distutils installed project and thus we cannot accurat
You must install signalwire-client-c to build mod_signalwire
You must install signalwire-client-c to build mod_signalwire
233 0
You must install libks to build mod_signalwire
You must install libks to build mod_signalwire
184 0
|
Ruby Perl
pod警告/Users/Codeliu/.rvm/gems/ruby-2.5.0/gems/cocoapods-1.4.0/lib/cocoapods/executable.rb:89:
pod警告/Users/Codeliu/.rvm/gems/ruby-2.5.0/gems/cocoapods-1.4.0/lib/cocoapods/executable.rb:89:
102 0
|
JavaScript
Nodejs pkg打包
nodejs打包
644 0
Nodejs pkg打包
pnpm add <pkg>
pnpm add <pkg>
162 0
pkg 打包
pkg 打包
250 0
|
Android开发 iOS开发 Perl
Flutter Warning: CocoaPods not installed. Skipping pod install.
Flutter Warning: CocoaPods not installed. Skipping pod install.
685 0