Electron 项目(一):使用 npm 创建项目

  1. 安装淘宝镜像:
    npm install -g cnpm --registry=https://registry.npm.taobao.org
  2. 全局安装 electron、electron-forge、electron-prebuilt-compile:
    cnpm install -g electron
    cnpm install -g electron-forge
    cnpm install -g electron-prebuilt-compile
  3. 使用 cmd 新建并进入 electron-demo 文件夹 :
    Microsoft Windows [版本 10.0.18363.836]
    (c) 2019 Microsoft Corporation。保留所有权利。
    
    E:\GitHub>mkdir electron-demo
    
    E:\GitHub>cd electron-demo
    
    E:\GitHub\electron-demo>
  4. 在 electron-demo 文件夹中新建文件 .npmrc,内容如下:
    registry=https://registry.npm.taobao.org
  5. 查看 electron-demo 文件夹中的文件:
    E:\GitHub\electron-demo>dir
     驱动器 E 中的卷是 文件
     卷的序列号是 26F3-A057
    
     E:\GitHub\electron-demo 的目录
    
    2020-05-23  15:49    <DIR>          .
    2020-05-23  15:49    <DIR>          ..
    2020-05-23  15:49                42 .npmrc
                   1 个文件             42 字节
                   2 个目录 251,371,405,312 可用字节
    
    E:\GitHub\electron-demo>
  6. 使用 electron-forge 创建项目,.npmrc 文件配置 npm 使用的镜像地址:
    安装过程会提示:
    警告:指定的路径:“E:\GitHub\electron demo”不为空,是否继续?
    继续即可。
    E:\GitHub\electron-demo>electron-forge init
    √ Checking your system
    ? WARNING: The specified path: "E:\GitHub\electron-demo" is not empty, do you wish to continue? Yes
    √ Initializing Project Directory
    √ Initializing Git Repository
    √ Copying Starter Files
    √ Initializing NPM Module
    √ Installing NPM Dependencies
    
    E:\GitHub\electron-demo>
  7. 运行项目:
    E:\GitHub\electron-demo>npm start
    
    > [email protected] start E:\GitHub\electron-demo
    > electron-forge start
    
    √ Checking your system
    √ Locating Application
    √ Preparing native dependencies
    √ Launching Application
    
    (electron) 'setName function' is deprecated and will be removed. Please use 'name property' instead.
    (electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false".  It will change to be "true" in Electron 9.  For more information please check https://github.com/electron/electron/issues/18397
    
  8. 运行结果:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章