javascript Mindee API抛出错误-错误:无法找到模块“node:buffer”

cotxawn7  于 2023-04-10  发布在  Java
关注(0)|答案(1)|浏览(174)

我正在探索Mindee来编写一个将pdf转换为文本的代码,所以我遵循了这些步骤并使用了文档中的代码,但是当我用node运行它时,它抛出了这个错误:

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'node:buffer'
Require stack:
- C:\Users\budgi\OneDrive\Documentos\TrabajosBi\Proy\Fedex\v2\node_modules\mindee\src\inputs\sources.js
- C:\Users\budgi\OneDrive\Documentos\TrabajosBi\Proy\Fedex\v2\node_modules\mindee\src\inputs\index.js
- C:\Users\budgi\OneDrive\Documentos\TrabajosBi\Proy\Fedex\v2\node_modules\mindee\src\client.js
- C:\Users\budgi\OneDrive\Documentos\TrabajosBi\Proy\Fedex\v2\node_modules\mindee\src\index.js
- C:\Users\budgi\OneDrive\Documentos\TrabajosBi\Proy\Fedex\v2\app.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:\Users\budgi\OneDrive\Documentos\TrabajosBi\Proy\Fedex\v2\node_modules\mindee\src\inputs\sources.js:30:23)
    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 Module.require (internal/modules/cjs/loader.js:952:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\budgi\\OneDrive\\Documentos\\TrabajosBi\\Proy\\Fedex\\v2\\node_modules\\mindee\\src\\inputs\\sources.js',
    'C:\\Users\\budgi\\OneDrive\\Documentos\\TrabajosBi\\Proy\\Fedex\\v2\\node_modules\\mindee\\src\\inputs\\index.js',
    'C:\\Users\\budgi\\OneDrive\\Documentos\\TrabajosBi\\Proy\\Fedex\\v2\\node_modules\\mindee\\src\\client.js',
    'C:\\Users\\budgi\\OneDrive\\Documentos\\TrabajosBi\\Proy\\Fedex\\v2\\node_modules\\mindee\\src\\index.js',
    'C:\\Users\\budgi\\OneDrive\\Documentos\\TrabajosBi\\Proy\\Fedex\\v2\\app.js'
  ]
}

以下是文件夹:folders
和app.js(从文档中粘贴代码)

const mindee = require("mindee");
// for TS or modules:
// import * as mindee from "mindee";

// Init a new client
const mindeeClient = new mindee.Client({apiKey: "1234567890"});

// Load a file from disk and parse it
const invoiceResponse = mindeeClient
    .docFromPath("/path/to/the/invoice.pdf")
    .parse(mindee.InvoiceV3);

// Print a the parsed data
invoiceResponse.then((resp) => {

  // The document property can be undefined:
  // * TypeScript will throw an error without this guard clause
  //   (or consider using '?' notation)
  // * JavaScript will be very happy to produce subtle bugs
  //   without this guard clause
  if (resp.document === undefined) return;

  // full object
  console.log(resp.document);
    
  // string summary
  console.log(resp.document.toString());
});

错误的原因是什么?

gmxoilav

gmxoilav1#

您使用的是什么版本的mindeenodeJS
我想,你应该尝试使用另一个版本的mindee .也许,甚至nodeJS,但它不太可能.

相关问题