xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

npm 安装 electron 失败的解决方案

npm 安装 electron 失败的解决方案

shit GFW

npm 安装 electron 失败

解决方案

https://www.npmjs.com/package/nrm

$ nrm ls

$ nrm use cnpm

$ npm i electron

# 还原
$ nrm use npm

demo

"use strict";

/**
 *
 * @author xgqfrms
 * @license MIT
 * @copyright xgqfrms
 * @created 2020-11-01
 * @modified
 *
 * @description
 * @difficulty Easy Medium Hard
 * @complexity O(n)
 * @augments
 * @example
 * @link
 * @solutions
 *
 * @best_solutions
 *
 */

const log = console.log;

log(`__dirname`, __dirname)

const { app, BrowserWindow } = require('electron')

function createWindow () {
  const win = new BrowserWindow({
    width: 1000,
    height: 700,
    webPreferences: {
      nodeIntegration: true
    }
  })

  // win.loadFile('index.html');
  // win.loadFile(__dirname + '/index.html');
  win.loadFile(__dirname.replace(`src`, ``) + '/public/index.html');
  // 打开 debug 模式
  win.webContents.openDevTools();
}

app.whenReady().then(createWindow)

app.on('window-all-closed', () => {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', () => {
  if (BrowserWindow.getAllWindows().length === 0) {
    createWindow()
  }
})

refs



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2020-11-16 08:27  xgqfrms  阅读(1177)  评论(1编辑  收藏  举报