nashaofu / node-screenshots

Zero-dependent. A native nodejs screenshots library for Mac、Windows、Linux.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Windows10下部分机型报错问题

ByLiangCheng opened this issue · comments

ef1a7e01a1e262c186451359449bbc0

Windows10的版本为专业版

如图所示,只要应用窗口页面引入了包:import { Screenshots } from 'node-screenshots'

在启动的时候,部分windows10系统就会提示图中的这个错误,导致应用无法启动

目前部分电脑的解决方案是重新更新了电脑dll库解决的,还有部分目前无法解决

这个有更好的解决方案吗?

  1. 你在有问题的机器上,安装node-screenshots,然后执行下面的js代码,看看是否会报错
const { Screenshots } = require('node-screenshots')
  1. 找到 electron 打包后的resources文件夹,看看里面的node_modules是否包含对应的模块,如果没有也可以解压asar这个文件,看看里面的node_modules是否包含对应模块。可参考这个排查一下https://github.com/nashaofu/screenshots/blob/master/packages/electron-screenshots/README.md#%E6%B3%A8%E6%84%8F

尝试运行代码没有报错
const { Screenshots } = require('node-screenshots')

node_modules包含对应的模块

使用上述链接中的方式好像也没有效果

这个问题看起来是你打包后node_modules下面没有node-screenshots.win32-x64-msvc.node这个文件,你排查一下吧,并不是电脑dll文件问题,因为你直接运行const { Screenshots } = require('node-screenshots')是可以的

好的,我再排查一下,谢谢回复

commented

Maybe will help.

  1. Download or clone git repository
  2. Navigate CMD to that folder (google command cd)
  3. Run command npm install
  4. Run command npm run build
  5. In project root folder you gonna have .node file, require it in any of your projects.

My usage is like this, cuz I only need fullscreen shots:

const PRIMARY_DISPLAY = require('./node-screenshots.win32-x64-msvc.node').Screenshots.fromPoint(0, 0);
/* some logic */
const shot = PRIMARY_DISPLAY.captureSync();

window10下我也遇到相同问题,有人知道如何解决吗。感谢

window10下我也遇到相同问题,有人知道如何解决吗。感谢

我是Electron开发环境,但是上一次在提交这个issues时不知道是否因为测试有误还是环境问题,没有复现出来

后面我的应用发版后,持续有部分用户反馈这个问题,让他们尝试更新dll库后就可以正确运行了,所以暂时确认是用户电脑缺少dll导致

后面也看到eSearch项目引入了此库, 并在issues看到也存在这个问题 eSearch 的 issues #123
看他的解决方案就是安装VC_redist.x64.exe,

参考他的部分代码后,我现在的解决方案:

打包应用时一起把VC_redist.x64.exe一起打包进去,并在builder-installer.nsh内配置了,当安装应用时触发调起VC_redist.x64.exe安装,这样可以保证用户在使用时dll库是完整的

具体builder-installer.nsh实现可以参考: TTime builder-installer.nsh

这里是我打包出来的一个可执行文件screenshots.zip,下载解压后,在命令行执行./screenshots.exe看看是否能正常执行,以帮助我确定是screenshots-rs这个库有问题还是napi-rs的问题。
image