AWS Lambda中的PhantomJS(缺lesslibfontconfig)

我试图让我的lambda函数使用phantomjs,但它一直运行到一个缺less的依赖关系的错误:libfontconfig / fontconfig。 在我的Centos VPS上安装fontconfig(dnf install fontconfig -y)时,我的代码工作正常。 然而,在lambda上运行时,我无法弄清楚如何让这个库运行我的function。

这是我的代码:(试图通过使用phantomjs的AliExpress软件包获得最畅销的产品)

const aliExpress = require('aliexpress'); exports.handler = (event, context, callback) => { console.log('Handler ran!'); aliExpress.BestSelling.get().then((goods) => { console.log('Found results!'); const urls = []; for(let index in goods) { const url = goods[index].url; urls.push(url); } console.log('Returning URLs:'); console.log(urls); callback(null, urls); }).catch((err) => { console.log('Error:'); console.log(err); callback(err); }); }; // For testing on VPS exports.handler(null, null, (err, result) => { if(err) { console.log('Err:'); console.log(err); } else { console.log('Result:'); console.log(result); } }); 

我期待的结果是一个AliExpressurl的数组,这是每当我运行与我的VPS上安装的fontconfig时会发生什么。 但是,在我的lambda函数和我的VPS没有安装fontconfig我得到这个错误:

 Handler ran! (node:1966) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error reading from stdin: Error: write EPIPE (node:1966) [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. error: /home/function/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory 

我相信我现在要么1)找出如何运行phantomjs没有这种依赖或2)弄清楚如何安装这个依赖关系到我的Lambda函数的“服务器”

也许有一个phantomjs以前的版本,给我的function,我想要没有这种依赖? 不确定

任何人都知道我可以如何解决这个问题? 谢谢!