npm pdfkittable ENOENT 用于在 EC2 中从本地读取文件

npm pdfkittable ENOENT for reading file from locally in EC2

我的 Express App 以以下 error 结束,而 pdfkittable[=] 的 运行 代码28=] 在 AWS EC2 中,但 在我的本地系统中工作正常

.

Error: ENOENT: no such file or directory, open './images/145.jpg'
May 17 01:51:56 ip-172-31-15-xxx my-node-server: at Object.openSync (node:fs:585:3)
May 17 01:51:56 ip-172-31-15-xxx my-node-server: at Object.readFileSync (node:fs:453:35)
May 17 01:51:56 ip-172-31-15-xxx my-node-server: at getImageBuffer (/home/ec2-user/miassessment/pdf-service.js:41:15)
May 17 01:51:56 ip-172-31-15-xxx my-node-server: at Object.miReportGenerator (/home/ec2-user/miassessment/pdf-service.js:47:25)
May 17 01:51:56 ip-172-31-15-xxx my-node-server: at Process.reportGeneration (/home/ec2-user/miassessment/backendFuntions.js:489:20)
May 17 01:51:56 ip-172-31-15-xxx my-node-server: at processTicksAndRejections (node:internal/process/task_queues:96:5) {
May 17 01:51:56 ip-172-31-15-xxx my-node-server: errno: -2,
May 17 01:51:56 ip-172-31-15-xxx my-node-server: syscall: 'open',
May 17 01:51:56 ip-172-31-15-xxx my-node-server: code: 'ENOENT',
May 17 01:51:56 ip-172-31-15-xxx my-node-server: path: './images/145.jpg'
May 17 01:51:56 ip-172-31-15-xxx my-node-server: }

该文件存在于根目录下的 /images 目录中。

要读取的图像文件存在于

/miassessment/images/145.jpg

代码运行在

/miassessment/pdf-service.js

为 EC2 提供图像 '/home/ec2-user/miassessment/images/145.jpg' 的绝对路径。