imported package deploys as if it has no module parent. #12326
Replies: 7 comments
-
Did you find a solution to this? It seems to fire on import.
|
Beta Was this translation helpful? Give feedback.
-
I haven’t, but I agree with you. It seems as though “isDebugMode” is
getting set to true, triggering the tests on import but I haven’t figured
out how to prevent it.
…On Thu, Jan 18, 2024 at 8:27 AM Dommo ***@***.***> wrote:
Did you find a solution to this? It seems to fire on import.
import Pdf from 'pdf-parse';
—
Reply to this email directly, view it on GitHub
<#12326 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A3RGYMDZ63XZHSUB2IBWQ2TYPEPNJAVCNFSM6AAAAABB5QMQKSVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DCNRZGI4TK>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I also encountered the same problem |
Beta Was this translation helpful? Give feedback.
-
Did you ever find a solution to this? |
Beta Was this translation helpful? Give feedback.
-
Just change the isDebugMode variable to false in node_modules/pdf-parse/index.js |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
I understood the problem. That's why you must use CommonJS. |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm working on adding pdf parsing functionality to a project that uses the Serverless Framework. The package I am using to add this functionality is "pdf-parse" and I am importing it into my chunk.ts file by using the statement "import PdfParse from 'pdf-parse' ". My project is written in typescript and deploys on AWS. during deployment, the code is converted to js and then deployed to a Lambda function. When the Lambda function runs I keep getting an ENOENT error. I found that the file it is looking for is one of the test .pdf files in the pdf-parse package, and that should only be triggered if the module has no parent. In this case, I am importing the pdf-parse module, so this code should not be running. I am not sure why this is happening and would appreciate any insight into why the package isn't importing correctly. When it runs correctly it should parse the text from the pdf document when it is called.
The error I am getting in CloudWatch after the resulting Lambda is triggered is this:
{
"errorType": "Error",
"errorMessage": "ENOENT: no such file or directory, open './test/data/05-versions-space.pdf'",
"code": "ENOENT",
"errno": -2,
"syscall": "open",
"path": "./test/data/05-versions-space.pdf",
"stack": [
"Error: ENOENT: no such file or directory, open './test/data/05-versions-space.pdf'",
" at Object.openSync (node:fs:603:3)",
" at Object.readFileSync (node:fs:471:35)",
" at node_modules/pdf-parse/index.js (/var/task/src/handlers/chunk.js:282056:27)",
" at __require (/var/task/src/handlers/chunk.js:18:50)",
" at Object. (/var/task/src/handlers/chunk.js:282126:16)",
" at Module._compile (node:internal/modules/cjs/loader:1256:14)",
" at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)",
" at Module.load (node:internal/modules/cjs/loader:1119:32)",
" at Module._load (node:internal/modules/cjs/loader:960:12)",
" at Module.require (node:internal/modules/cjs/loader:1143:19)"
]
}
The base code for the project I am modifying can be found at this link:
https://github.com/mikaelvesavuori/bedrock-rag-demo
I have made minimal changes to enable pdf parsing and have attached my modified chunk.ts file to this post.
chunk.ts.zip
Thanks in advance for your help
Beta Was this translation helpful? Give feedback.
All reactions