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. 運行結果:
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章