@google-cloud/document-ai Typescript NodeJS Build Error
localhostd3veloper opened this issue · comments
Environment details
- which product (packages/*): @google-cloud/document-ai
- OS: Ubuntu 22.04.3
- Node.js version: v18.18.2
- npm version: 9.8.1
- google-cloud-node version:
- @google-cloud/documentai: ^8.1.1
Steps to reproduce
I am using the client library for Document AI using Node.JS with the help of this url
https://cloud.google.com/document-ai/docs/samples/documentai-quickstart?hl=en#documentai_quickstart-nodejs
The project is working completely fine when running locally. But when building, it gives this error in one of the dependencies used by client library named as long
-> 5.2.3
Actual Error while Building
The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../index.js")' call instead
I am using tsc
command to build the project
Thanks!
Hi @localhostd3veloper, I think this issue has to do with your typescript configuration. However, you shouldn't need to install those dependencies anyways since they're development dependencies. It looks like you're using .pnpm
, could you try running: rm -rf node_modules && pnpm i --prod
, then try rebuilding?
Going to close for now, feel free to reopen if it keeps being an issue!