本篇目录
- 1. 安装 pkg
- 2. 下载项目依赖
- 3. 初始化并安装 express 包
- 4. 开始打包
- 5. 打包完成
- 6. 问题处理
- 6.1 打包过程报错
- 附录🤗
- 1. 手动下载 node 二进制文件
前期准备:🙂
- 确保本地网络可以访问 Github。
- 确保本地正确安装 NodeJs,可使用 node -v 查看版本。
- 确保待打包项目可正常运行。
- 本篇 NodeJs 版本 v14.15.1。
本篇介绍使用 pkg 插件将 Vue 项目打包成 exe 文件;前期准备完成之后,cmd 进入项目根目录,执行以下步骤:
1. 安装 pkg
全局安装 pkg ,执行命令 npm i -g pkg
。
> npm i -g pkg
C:\setup\nodejs\pkg -> C:\setup\nodejs\node_modules\pkg\lib-es5\bin.js
+ pkg@5.8.1
added 127 packages from 94 contributors in 18.848s
2. 下载项目依赖
执行命令npm install
下载项目依赖。
> npm install
npm WARN webstatic@1.0.0 No description
npm WARN webstatic@1.0.0 No repository field.up to date in 10.433s14 packages are looking for fundingrun `npm fund` for details
3. 初始化并安装 express 包
执行命令 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