近期因项目需要,在树莓派上需要将本地网页打包成APP,便使用nativefier来完成,但是出现了一些小插曲,记录在此。
环境:树莓派4B4G版本,系统为raspibian32位
nativefier可以一键打包网页成一个应用,操作方法也很简单,就是命令行输入:nativefier [网址]
详情见:https://github.com/jiahaog/nativefier#usage
但是在树莓派上使用出现了三个问题,具体问题及解决办法如下:
问题1:arch无法自动选择位armv7l:
Error during build. Run with --verbose for details. Error: Unsupported arch=arm (string); must be a string matching: ia32, x64, armv7l, arm64, mips64el at unsupportedListOption (/usr/local/lib/node_modules/nativefier/node_modules/electron-packager/src/targets.js:64:10) at Object.validateListFromOptions (/usr/local/lib/node_modules/nativefier/node_modules/electron-packager/src/targets.js:134:16) at packager (/usr/local/lib/node_modules/nativefier/node_modules/electron-packager/src/index.js:167:25) at Object.buildNativefierApp (/usr/local/lib/node_modules/nativefier/src/build/buildNativefierApp.ts:118:30)但是执行uname -a命令可以看到树莓派就是armv7l,但是nativefier会识别为arm,原因不明。
解决方法:添加参数 “-a armv7l"
问题2:打包完成后启动时出现failed to load swrast driver的情况:
MESA-LOADER: failed to retrieve device information MESA-LOADER: failed to retrieve device information MESA-LOADER: failed to retrieve device information MESA-LOADER: failed to open kms_swrast (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri) failed to load driver: kms_swrast MESA-LOADER: failed to open swrast (search paths /usr/lib/arm-linux-gnueabihf/dri:\$${ORIGIN}/dri:/usr/lib/dri) failed to load swrast driver这多半是驱动问题,搜索良久无果,无奈选择关闭OPENGL,见:https://www.zhihu.com/question/268198765
sudo raspi-config ->Advanced Options ->GL Driver 选第二个。 重启 sudo raspi-config ->Advanced Options ->GL Driver 选第一个(Legacy)。 重启亲测有效。
问题三:弹窗提示JavaScript error
此处不方便截图,但是报错为"Image could not be created"
此问题在nativefier issue中已经解决,地址:https://github.com/jiahaog/nativefier/issues/992
具体解决方法为,在原有命令基础上添加”--verbose -e 8.3.2"来选择electron版本。
目前问题已经解决,如有其他问题请留言一同探讨。