pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

將 console.log() 與電子一起使用

using console.log() with electron(將 console.log() 與電子一起使用)
本文介紹了將 console.log() 與電子一起使用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我已經看到很多人試圖從渲染過程中控制日志,這不是我的問題我有 console.log 亂扔我的主要代碼,我在控制臺中看不到任何東西這是我的代碼.

I have seen a lot of questions from people trying to console log from the rendering process, this is NOT my problem I have console.log littering my main code and I don't see anything in my console here is my code.

/* eslint-disable no-undef */
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
const url = require('url');
/* eslint-enable */

let win;

console.log('console log test');

function createWindow() {
  win = new BrowserWindow({
    width: 800,
    height: 800
  });

  win.loadURL(url.format({
    pathname: path.join(__dirname, 'index.html'),
    protocol: 'file:',
    slashes: true
  }));

  win.on('close', () => {
    win = null;
  });

  console.log('console log test');
}

app.on('ready', createWindow);

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

app.on('activate', () => {
  if (win == null) {
    console.log('console log test');
    createWindow();
    console.log('console log test');
  }
});

除了電子本身產生的日志之外,我沒有看到任何日志我嘗試拋出錯誤并且這些工作正常,但是任何與控制臺相關的東西都不起作用,我嘗試在 PowerShell 中運行它并從 GitHub 重新拉取,我的朋友在拉取項目時可以看到控制臺日志雖然如此看來我是孤立的.我還更新了 NPM 和與項目相關的所有模塊,并且我嘗試創建一個新控制臺并登錄到該控制臺,但它似乎沒有出現,我錯過了什么嗎?我已經為此投入了數小時,并準備放棄.

I don't see a single log other than the ones produced by electron itself I've tried throwing errors and those work fine but anything console.* related doesn't work at all, I've tried running it in PowerShell and re-pulling from GitHub, my friend can see the console logs when he pulls the project though so it seems I'm isolated. I've also updated NPM and all modules associated with the project AND I've tried creating a new console and logging to that one but it doesn't seem to show up, am I missing something? I've put hours into this and am ready to give up.

推薦答案

我感覺到你的痛苦.我的一個盒子(一個 Server2012 盒子)有這個問題.直到我偶然發現 此評論 上的一個電子對我有用問題線程.

I feel your pain. I have this issue on one of my boxes (a Server2012 box). Nothing worked for me until I stumbled across this comment on one of the electron issues threads.

通常,當您安裝 electron 時,您的 package.json 中會有一個如下所示的腳本.

Typically when you install electron you will have a script in your package.json that looks like this.

"scripts": {
    "start": "electron .",
}

我改成了

"scripts": {
    "start": "C:/path/to/project/node_modules/electron-prebuilt/dist/electron.exe .",
}

我開始從 powershell 中的主電子進程獲取日志記錄.

And I started to get logging from the main electron process in powershell.

請注意,如果您使用較新版本的電子,您可能需要將 electron-prebuilt 更改為 electron.

Note that if you are using newer versions of electron, you may need to change electron-prebuilt to electron.

這篇關于將 console.log() 與電子一起使用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 颚式破碎机,圆锥破碎机,制砂机-新乡市德诚机电制造有限公司 | 无菌检查集菌仪,微生物限度仪器-苏州长留仪器百科 | 天然鹅卵石滤料厂家-锰砂滤料-石英砂滤料-巩义东枫净水 | 啤酒设备-小型啤酒设备-啤酒厂设备-济南中酿机械设备有限公司 | 定时排水阀/排气阀-仪表三通旋塞阀-直角式脉冲电磁阀-永嘉良科阀门有限公司 | 电缆故障测试仪_电缆故障定位仪_探测仪_检测仪器_陕西意联电气厂家 | 莱州网络公司|莱州网站建设|莱州网站优化|莱州阿里巴巴-莱州唯佳网络科技有限公司 | 365文案网_全网创意文案句子素材站 | 直线模组_滚珠丝杆滑台_模组滑台厂家_万里疆科技 | 优宝-汽车润滑脂-轴承润滑脂-高温齿轮润滑油脂厂家 | 脑钠肽-白介素4|白介素8试剂盒-研域(上海)化学试剂有限公司 | 云阳人才网_云阳招聘网_云阳人才市场_云阳人事人才网_云阳人家招聘网_云阳最新招聘信息 | 青岛美佳乐清洁工程有限公司|青岛油烟管道清洗|酒店|企事业单位|学校工厂厨房|青岛油烟管道清洗 插针变压器-家用电器变压器-工业空调变压器-CD型电抗器-余姚市中驰电器有限公司 | 小型玉石雕刻机_家用玉雕机_小型万能雕刻机_凡刻雕刻机官网 | 北京遮阳网-防尘盖土网-盖土草坪-迷彩网-防尘网生产厂家-京兴科技 | 附着力促进剂-尼龙处理剂-PP处理剂-金属附着力处理剂-东莞市炅盛塑胶科技有限公司 | 艺术涂料|木纹漆施工|稻草漆厂家|马来漆|石桦奴|水泥漆|选加河南天工涂料 | 原色会计-合肥注册公司_合肥代理记账公司_营业执照代办 | 膜结构_ETFE膜结构_膜结构厂家_膜结构设计-深圳市烨兴智能空间技术有限公司 | 北京中航时代-耐电压击穿试验仪厂家-电压击穿试验机 | 南汇8424西瓜_南汇玉菇甜瓜-南汇水蜜桃价格 | ge超声波测厚仪-电动涂膜机-电动划格仪-上海洪富 | 考勤系统_人事考勤管理系统_本地部署BS考勤系统_考勤软件_天时考勤管理专家 | 青岛代理记账_青岛李沧代理记账公司_青岛崂山代理记账一个月多少钱_青岛德辉财税事务所官网 | 小区健身器材_户外健身器材_室外健身器材_公园健身路径-沧州浩然体育器材有限公司 | 安徽合肥项目申报咨询公司_安徽合肥高新企业项目申报_安徽省科技项目申报代理 | 光照全温振荡器(智能型)-恒隆仪器 | 步入式高低温测试箱|海向仪器 | 并网柜,汇流箱,电控设备,中高低压开关柜,电气电力成套设备,PLC控制设备订制厂家,江苏昌伟业新能源科技有限公司 | 辐射色度计-字符亮度测试-反射式膜厚仪-苏州瑞格谱光电科技有限公司 | 北京律师咨询_知名专业北京律师事务所_免费法律咨询 | 暴风影音 | 玻纤土工格栅_钢塑格栅_PP焊接_单双向塑料土工格栅_复合防裂布厂家_山东大庚工程材料科技有限公司 | 杭州月嫂技术培训服务公司-催乳师培训中心报名费用-产后康复师培训机构-杭州优贝姆健康管理有限公司 | 次氯酸钠厂家,涉水级次氯酸钠,三氯化铁生产厂家-淄博吉灿化工 | 12cr1mov无缝钢管切割-15crmog无缝钢管切割-40cr无缝钢管切割-42crmo无缝钢管切割-Q345B无缝钢管切割-45#无缝钢管切割 - 聊城宽达钢管有限公司 | 学叉车培训|叉车证报名|叉车查询|叉车证怎么考-工程机械培训网 | 板框压滤机-隔膜压滤机配件生产厂家-陕西华星佳洋装备制造有限公司 | 深圳工程师职称评定条件及流程_深圳职称评审_职称评审-职称网 | 北京发电车出租-发电机租赁公司-柴油发电机厂家 - 北京明旺盛安机电设备有限公司 | 多功能干燥机,过滤洗涤干燥三合一设备-无锡市张华医药设备有限公司 |