Electron- UnhandledPromiseRejectionWarning: Error: Image could not be created from

博客讲述在Mac电脑上运行Electron相关工程时出现报错,提示无法从指定路径创建图像,还给出了错误的起源及相关警告信息,最后提及有解决方案和工程地址。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在mac电脑上运行工程。 报错

 

(node:14437) UnhandledPromiseRejectionWarning: Error: Image could not be created from ./logo.ico
    at createWindow (/xxx/react-typescript-quick-electron/app/index.js:16:15)
(node:14437) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14437) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
 

解决方案:

const {**, nativeImage,**} = require('electron')

 const win = new BrowserWindow({
        icon: nativeImage.createFromPath('./logo.ico')
    })

 

工程地址

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值