amazon-textract-response-parser icon indicating copy to clipboard operation
amazon-textract-response-parser copied to clipboard

NodeJS import/require errors

Open mattmcgiv opened this issue 2 years ago • 2 comments

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' ]
}

mattmcgiv avatar Oct 15 '21 14:10 mattmcgiv

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.

mattmcgiv avatar Oct 15 '21 14:10 mattmcgiv

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!

athewsey avatar Oct 26 '21 12:10 athewsey

Hi, shouldn't this issue be closed since it's been merged?

linuxatico avatar Apr 14 '23 16:04 linuxatico

^ Yes: v0.1.2 is long since merged and released: Closing this issue as believe it to be fixed.

athewsey avatar May 11 '23 11:05 athewsey