How to package node.js into multi-platform binary executable files
This article mainly introduces "how to package node.js into multi-platform binary executable files". In daily operation, I believe many people have doubts about how to package node.js into multi-platform binary executable files. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to package node.js into multi-platform binary executable files". Next, please follow the editor to study!
Vercel/pkg can help us compile node.js scripts into executable files and run them directly on linux, mac, and windows, such as app.exe.
1. Installation
Npm install-g pkg
two。 Compile
Pkg index.js-t node14-macos-x64-- out-path bin
If ⚠️ does not add the-t parameter, three versions of linux, mac and windows will be compiled by default.
⚠️-- the out-path parameter determines the directory where the compiled files are stored.
⚠️ is slow to package for the first time because there is no cache
At this point, the study on "how to package node.js into a multi-platform binary executable file" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!