Electron - 初体验
Posted xzdm
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Electron - 初体验相关的知识,希望对你有一定的参考价值。
Electron 的安装
使用 electron-forge 脚手架
> npm install -g electron-forge
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated wrench@1.5.9: wrench.js is deprecated! You should check out fs-extra (https://github.com/jprichardson/node-fs-extra) for any operations you were using wrench for. Thanks for all the usage over the years.
npm WARN deprecated natives@1.1.6: This module relies on Node.js‘s internals and will break at some point. Do not use it, and update to graceful-fs@4.x.
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
> electron-forge init my-app
electron-forge : 无法加载文件 C:Users****AppDataRoaming
pmelectron-forge.ps1,因为在此系统上禁止运行脚本。有关详
细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ electron-forge init my-app
+ ~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [],PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
安装过程正常,但是创建项目出现问题,原因是需要开启一个注册表的权限许可
- windows 左下搜 powershell,管理员运行
- 按照报错信息处理重新初始化即可
使用官方推荐的初始化项目包
-
克隆示例项目的仓库
git clone https://github.com/electron/electron-quick-start
-
进入这个仓库
cd electron-quick-start
-
安装依赖并运行
npm install
npm start
安装过程有一个文件下载很慢
Downloading electron-v9.0.5-win32-x64.zip: [-----------------------------------------------------] 0% ETA: 0.0 seconds 终止批处理操作吗(Y/N)? y
设置单个包的安装地址,将其指向淘宝镜像
npm set ELECTRON_MIRROR=https://npm.taobao.org/mirrors/electron/
继续安装就可以了
看到这个界面就是成功了
以上是关于Electron - 初体验的主要内容,如果未能解决你的问题,请参考以下文章