我正在使用jsreport
呈现HTML并生成PDF文件,并且它在本地运行,但在Lambda上,它会抛出此错误:
{
"errorMessage": "Error during rendering report: Cannot read property 'filter' of undefined",
"errorType": "TypeError",
"stackTrace": [
"Phantom.execute (/var/task/node_modules/jsreport-phantom-pdf/lib/phantom.js:169:53)",
"/var/task/node_modules/jsreport-core/lib/render/render.js:118:23",
"tryCatcher (/var/task/node_modules/bluebird/js/release/util.js:16:23)",
"Promise._settlePromiseFromHandler (/var/task/node_modules/bluebird/js/release/promise.js:512:31)",
"Promise._settlePromise (/var/task/node_modules/bluebird/js/release/promise.js:569:18)",
"Promise._settlePromise0 (/var/task/node_modules/bluebird/js/release/promise.js:614:10)",
"Promise._settlePromises (/var/task/node_modules/bluebird/js/release/promise.js:693:18)",
"Async._drainQueue (/var/task/node_modules/bluebird/js/release/async.js:133:16)",
"Async._drainQueues (/var/task/node_modules/bluebird/js/release/async.js:143:10)",
"Immediate.Async.drainQueues (/var/task/node_modules/bluebird/js/release/async.js:17:14)",
"runCallback (timers.js:672:20)",
"tryOnImmediate (timers.js:645:5)",
"processImmediate [as _immediateCallback] (timers.js:617:5)"
]
}
相同的环境变量,相同的Node版本。
答案 0 :(得分:1)
var phantom = this.definition.options.phantoms.filter(function (p) {
return p.version === request.template.phantom.phantomjsVersion
})
表示对象路径options.phantoms
未定义。
您必须检查Lambda中definitions
的设置方式。
答案 1 :(得分:0)
事实证明,这是该库的一个问题:node-app-root-path。
我通过将正确的rootDirectory
选项传递给jsreport来修复它。