amazon-textract-response-parser
amazon-textract-response-parser copied to clipboard
NodeJS import/require errors
I ran into an error while requiring the NodeJS version following an npm install.
NodeJS: v14.17.6
To reproduce:
npm init -y
npm install amazon-textract-response-parser # as per instructions in this package's top-level readme
touch index.js
echo 'const { TextractDocument, TextractExpense } = require("textract-response-parser");' >> index.js
node index.js
Output:
Error: Cannot find module 'textract-response-parser'
Require stack:
- /{...}/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> ({...}/index.js:1:47)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/{...}/index.js' ]
}
I believe the root cause is a mismatch between the npm package name amazon-textract-response-parser
and the documentation ...require("textract-response-parser");
It's worth noting that I also into an issue when using the import statement import { TextractDocument, TextractExpense } from "textract-response-parser";
I am happy to take a deeper look and create a PR if it's helpful.
Thanks for raising this @mattmcgiv and for trying out the JS variant!
I believe you're right and it's simply a matter of the README being incorrect: Should use the full amazon-textract-response-parser
, not textract-response-parser
.
I've fixed this in my working copy so we can try to clear it up in a maintenance release soon (the doc page on NPM won't update until next release). Please do let us know if for some reason switching the import name doesn't clear it up for you, or if you find any other issues!
Hi, shouldn't this issue be closed since it's been merged?
^ Yes: v0.1.2 is long since merged and released: Closing this issue as believe it to be fixed.