Vue2.0 | 将项目打包成exe文件

本篇目录

  • 1. 安装 pkg
  • 2. 下载项目依赖
  • 3. 初始化并安装 express 包
  • 4. 开始打包
  • 5. 打包完成
  • 6. 问题处理
    • 6.1 打包过程报错
  • 附录
    • 1. 手动下载 node 二进制文件

前期准备:

  1. 确保本地网络可以访问 Github。
  2. 确保本地正确安装 NodeJs,可使用 node -v 查看版本。
  3. 确保待打包项目可正常运行。
  4. 本篇 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
+ [email protected]
added 127 packages from 94 contributors in 18.848s

2. 下载项目依赖

执行命令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

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 

你可能感兴趣的:(#,Vue2.0,vue.js,node.js)