uni-app 云函数在本地可以正常运行 在云端运行失败
uni-app 云函数在本地可以正常运行 在云端运行失败
操作步骤:
在云端运行失败
预期结果:
可以正常运行
实际结果:
[html-pdf-co/ac1cc2f81707102501189151396/344976ms/ERROR] 云函数执行失败 Error: html-pdf: Unknown Error
/tmp/function/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: 1: /tmp/function/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: Syntax error: Unterminated quoted string
at ChildProcess.respond (/tmp/function/node_modules/html-pdf/lib/pdf.js:134:17)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
bug描述:
requestId: ac1cc2f81707102501189151396
[html-pdf-co/ac1cc2f81707102501189151396/344976ms/ERROR] 云函数执行失败 Error: html-pdf: Unknown Error
/tmp/function/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: 1: /tmp/function/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: Syntax error: Unterminated quoted string
at ChildProcess.respond (/tmp/function/node_modules/html-pdf/lib/pdf.js:134:17)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
2 回复
云端的node版本和本地不一样导致的, 比如阿里云和腾讯云默认是node8, 支付宝默认是node18, 而本地是node16
阿里云 也设置为 node16,本地也是 node 16, 貌似 phantomjs 在云上没有被正确安装