转换式文件NPM软件包无法在Elastic Beanstalk Amazon Linux 2上使用
成功部署后,当我运行文件转换脚本时,如文档中所述,转换失败了。我的转换脚本。
该脚本在本地Windows 10机器和Ubuntu 20.04 LTS
中完美运行
const { convertWordFiles } = require("convert-multiple-files");
const path = require("path");
async function test() {
try {
const infoOutput = await convertWordFiles(
path.resolve(__dirname, `../../temp/test02.docx`),
"pdf",
path.resolve(__dirname, `../../temp`)
);
} catch (err) {
console.log(err);
}
}
test();
Jul 5 11:30:02 web: /var/app/current/node_modules/convert-multiple-files/lib/utils/instdir/program/soffice.bin: error while loading shared libraries: libxslt.so.1: cannot open
shared object file: No such file or directory
Jul 5 11:30:02 web: Error: Error converting the file
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:68:19
Jul 5 11:30:02 web: at step (/var/app/current/node_modules/convert-multiple-files/lib/index.js:33:23)
Jul 5 11:30:02 web: at Object.next (/var/app/current/node_modules/convert-multiple-files/lib/index.js:14:53)
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:8:71
Jul 5 11:30:02 web: at new WrappedPromise (/var/app/current/node_modules/async-listener/es6-wrapped-promise.js:13:18)
Jul 5 11:30:02 web: at __awaiter (/var/app/current/node_modules/convert-multiple-files/lib/index.js:4:12)
Jul 5 11:30:02 web: at convertWordFiles (/var/app/current/node_modules/convert-multiple-files/lib/index.js:44:75)
Jul 5 11:30:02 web: at FileHandlerService.preparePreview (/var/app/current/src/services/fileHandler.js:67:9)
Jul 5 11:30:02 web: at prepareDocumentPreview (/var/app/current/src/subprocess/fileConverter.js:20:60)
Jul 5 11:30:02 web: at async process.<anonymous> (/var/app/current/src/subprocess/fileConverter.js:27:16)
Jul 5 11:30:02 web: Error: Error converting the file
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:68:19
Jul 5 11:30:02 web: at step (/var/app/current/node_modules/convert-multiple-files/lib/index.js:33:23)
Jul 5 11:30:02 web: at Object.next (/var/app/current/node_modules/convert-multiple-files/lib/index.js:14:53)
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:8:71
Jul 5 11:30:02 web: at new WrappedPromise (/var/app/current/node_modules/async-listener/es6-wrapped-promise.js:13:18)
Jul 5 11:30:02 web: at __awaiter (/var/app/current/node_modules/convert-multiple-files/lib/index.js:4:12)
Jul 5 11:30:02 web: at convertWordFiles (/var/app/current/node_modules/convert-multiple-files/lib/index.js:44:75)
Jul 5 11:30:02 web: at FileHandlerService.preparePreview (/var/app/current/src/services/fileHandler.js:67:9)
Jul 5 11:30:02 web: at prepareDocumentPreview (/var/app/current/src/subprocess/fileConverter.js:20:60)
Jul 5 11:30:02 web: at async process.<anonymous> (/var/app/current/src/subprocess/fileConverter.js:27:16) null
中 完美运行代码>,此部分不再存在,
Jul 5 11:30:02 web: /var/app/current/node_modules/convert-multiple-files/lib/utils/instdir/program/soffice.bin: error while loading shared libraries: libxslt.so.1: cannot open
shared object file: No such file or directory
这意味着库确实加载了。
但是这次我遇到了错误,没有任何线索,这是从以下行
Jul 5 11:30:02 web: Error: Error converting the file
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:68:19
的
Error: Command failed: /var/app/current/node_modules/convert-multiple-files/lib/utils/instdir/program/soffice.bin --headless --norestore --invisible --nodefault --nofirststartwizard --nolockcheck --nologo --convert-to pdf --outdir /var/app/current/temp '/var/app/current/temp/test02.docx'
at checkExecSyncError (child_process.js:616:11)
at Object.execSync (child_process.js:652:15)
at /var/app/current/node_modules/convert-multiple-files/lib/index.js:61:31
at step (/var/app/current/node_modules/convert-multiple-files/lib/index.js:33:23)
at Object.next (/var/app/current/node_modules/convert-multiple-files/lib/index.js:14:53)
at /var/app/current/node_modules/convert-multiple-files/lib/index.js:8:71
at new Promise (<anonymous>)
at __awaiter (/var/app/current/node_modules/convert-multiple-files/lib/index.js:4:12)
at convertWordFiles (/var/app/current/node_modules/convert-multiple-files/lib/index.js:44:75)
at test (/var/app/current/src/services/converter.js:6:30)
at Object.<anonymous> (/var/app/current/src/services/converter.js:16:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
status: 77,
signal: null,
output: [ null, <Buffer >, <Buffer > ],
pid: 4311,
stdout: <Buffer >,
stderr: <Buffer >
}
Error: Error converting the file
at /var/app/current/node_modules/convert-multiple-files/lib/index.js:69:19
at step (/var/app/current/node_modules/convert-multiple-files/lib/index.js:33:23)
at Object.next (/var/app/current/node_modules/convert-multiple-files/lib/index.js:14:53)
at /var/app/current/node_modules/convert-multiple-files/lib/index.js:8:71
at new Promise (<anonymous>)
at __awaiter (/var/app/current/node_modules/convert-multiple-files/lib/index.js:4:12)
at convertWordFiles (/var/app/current/node_modules/convert-multiple-files/lib/index.js:44:75)
at test (/var/app/current/src/services/converter.js:6:30)
at Object.<anonymous> (/var/app/current/src/services/converter.js:16:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
出来 这个问题有明显的原因,还是我错过了什么?
After a successful deployment, when I run the my file conversion script as mentioned in the docs the conversion fails. my conversion script.
the script runs perfectly in local windows 10 machine and ubuntu 20.04 lts
const { convertWordFiles } = require("convert-multiple-files");
const path = require("path");
async function test() {
try {
const infoOutput = await convertWordFiles(
path.resolve(__dirname, `../../temp/test02.docx`),
"pdf",
path.resolve(__dirname, `../../temp`)
);
} catch (err) {
console.log(err);
}
}
test();
The Error I got was this
Jul 5 11:30:02 web: /var/app/current/node_modules/convert-multiple-files/lib/utils/instdir/program/soffice.bin: error while loading shared libraries: libxslt.so.1: cannot open
shared object file: No such file or directory
Jul 5 11:30:02 web: Error: Error converting the file
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:68:19
Jul 5 11:30:02 web: at step (/var/app/current/node_modules/convert-multiple-files/lib/index.js:33:23)
Jul 5 11:30:02 web: at Object.next (/var/app/current/node_modules/convert-multiple-files/lib/index.js:14:53)
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:8:71
Jul 5 11:30:02 web: at new WrappedPromise (/var/app/current/node_modules/async-listener/es6-wrapped-promise.js:13:18)
Jul 5 11:30:02 web: at __awaiter (/var/app/current/node_modules/convert-multiple-files/lib/index.js:4:12)
Jul 5 11:30:02 web: at convertWordFiles (/var/app/current/node_modules/convert-multiple-files/lib/index.js:44:75)
Jul 5 11:30:02 web: at FileHandlerService.preparePreview (/var/app/current/src/services/fileHandler.js:67:9)
Jul 5 11:30:02 web: at prepareDocumentPreview (/var/app/current/src/subprocess/fileConverter.js:20:60)
Jul 5 11:30:02 web: at async process.<anonymous> (/var/app/current/src/subprocess/fileConverter.js:27:16)
Jul 5 11:30:02 web: Error: Error converting the file
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:68:19
Jul 5 11:30:02 web: at step (/var/app/current/node_modules/convert-multiple-files/lib/index.js:33:23)
Jul 5 11:30:02 web: at Object.next (/var/app/current/node_modules/convert-multiple-files/lib/index.js:14:53)
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:8:71
Jul 5 11:30:02 web: at new WrappedPromise (/var/app/current/node_modules/async-listener/es6-wrapped-promise.js:13:18)
Jul 5 11:30:02 web: at __awaiter (/var/app/current/node_modules/convert-multiple-files/lib/index.js:4:12)
Jul 5 11:30:02 web: at convertWordFiles (/var/app/current/node_modules/convert-multiple-files/lib/index.js:44:75)
Jul 5 11:30:02 web: at FileHandlerService.preparePreview (/var/app/current/src/services/fileHandler.js:67:9)
Jul 5 11:30:02 web: at prepareDocumentPreview (/var/app/current/src/subprocess/fileConverter.js:20:60)
Jul 5 11:30:02 web: at async process.<anonymous> (/var/app/current/src/subprocess/fileConverter.js:27:16) null
After that I had to install the two packages libxslt
and libSM
and this portions was not there anymore
Jul 5 11:30:02 web: /var/app/current/node_modules/convert-multiple-files/lib/utils/instdir/program/soffice.bin: error while loading shared libraries: libxslt.so.1: cannot open
shared object file: No such file or directory
which means library did load.
but this time i got error without any clue, that came from the following line
Jul 5 11:30:02 web: Error: Error converting the file
Jul 5 11:30:02 web: at /var/app/current/node_modules/convert-multiple-files/lib/index.js:68:19
I did put a console log in convert-multiple-files/lib/index.js:68
and I got the following output
Error: Command failed: /var/app/current/node_modules/convert-multiple-files/lib/utils/instdir/program/soffice.bin --headless --norestore --invisible --nodefault --nofirststartwizard --nolockcheck --nologo --convert-to pdf --outdir /var/app/current/temp '/var/app/current/temp/test02.docx'
at checkExecSyncError (child_process.js:616:11)
at Object.execSync (child_process.js:652:15)
at /var/app/current/node_modules/convert-multiple-files/lib/index.js:61:31
at step (/var/app/current/node_modules/convert-multiple-files/lib/index.js:33:23)
at Object.next (/var/app/current/node_modules/convert-multiple-files/lib/index.js:14:53)
at /var/app/current/node_modules/convert-multiple-files/lib/index.js:8:71
at new Promise (<anonymous>)
at __awaiter (/var/app/current/node_modules/convert-multiple-files/lib/index.js:4:12)
at convertWordFiles (/var/app/current/node_modules/convert-multiple-files/lib/index.js:44:75)
at test (/var/app/current/src/services/converter.js:6:30)
at Object.<anonymous> (/var/app/current/src/services/converter.js:16:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
status: 77,
signal: null,
output: [ null, <Buffer >, <Buffer > ],
pid: 4311,
stdout: <Buffer >,
stderr: <Buffer >
}
Error: Error converting the file
at /var/app/current/node_modules/convert-multiple-files/lib/index.js:69:19
at step (/var/app/current/node_modules/convert-multiple-files/lib/index.js:33:23)
at Object.next (/var/app/current/node_modules/convert-multiple-files/lib/index.js:14:53)
at /var/app/current/node_modules/convert-multiple-files/lib/index.js:8:71
at new Promise (<anonymous>)
at __awaiter (/var/app/current/node_modules/convert-multiple-files/lib/index.js:4:12)
at convertWordFiles (/var/app/current/node_modules/convert-multiple-files/lib/index.js:44:75)
at test (/var/app/current/src/services/converter.js:6:30)
at Object.<anonymous> (/var/app/current/src/services/converter.js:16:1)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
is there any obvious reason for the problem or am I missing anything ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,经过一些调试后,我发现这实际上是一个许可问题,我最终为我的Elastic Beanstalk环境编写了
config
file,文件的内容得到了bellowSo after a bit of debugging I figured out that it was actually a permission issue and I ended up writing a
config
file for my elastic beanstalk environment, the contents of the file are given bellow