转换式文件NPM软件包无法在Elastic Beanstalk Amazon Linux 2上使用

发布于 2025-02-13 08:10:30 字数 6406 浏览 2 评论 0原文

成功部署后,当我运行文件转换脚本时,如文档中所述,转换失败了。我的转换脚本。

该脚本在本地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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱桃奶球 2025-02-20 08:10:31

因此,经过一些调试后,我发现这实际上是一个许可问题,我最终为我的Elastic Beanstalk环境编写了config file,文件的内容得到了bellow

commands:
    01-install_dependencies:
        command: sudo yum install libxslt libSM
        cwd: /home/ec2-user
    02-update_cache:
        command: sudo /sbin/ldconfig -v
        cwd: /home/ec2-user
    03-provide_write_permission_to_convert_multiple_files_lib:
        command: sudo chmod -R 777 /var/app/current/node_modules/convert-multiple-files/*
        cwd: /home/ec2-user

So 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

commands:
    01-install_dependencies:
        command: sudo yum install libxslt libSM
        cwd: /home/ec2-user
    02-update_cache:
        command: sudo /sbin/ldconfig -v
        cwd: /home/ec2-user
    03-provide_write_permission_to_convert_multiple_files_lib:
        command: sudo chmod -R 777 /var/app/current/node_modules/convert-multiple-files/*
        cwd: /home/ec2-user
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文