前期准备:
- 确保本地网络可以访问 Github。
- 确保本地正确安装 NodeJs,可使用 node -v 查看版本。
- 确保待打包项目可正常运行。
- 本篇 NodeJs 版本 v14.15.1。
本篇介绍使用 pkg 插件将 Vue 项目打包成 exe 文件;前期准备完成之后,cmd 进入项目根目录,执行以下步骤:
全局安装 pkg ,执行命令 npm i -g pkg
。
> npm i -g pkg
C:\setup\nodejs\pkg -> C:\setup\nodejs\node_modules\pkg\lib-es5\bin.js
+ [email protected]
added 127 packages from 94 contributors in 18.848s
执行命令npm install
下载项目依赖。
> npm install
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
up to date in 10.433s
14 packages are looking for funding
run `npm fund` for details
执行命令 npm init & npm i -D express
,执行过程中的步骤,直接 Enter 默认下一步。
> npm init & npm i -D express
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help init` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any