long.js icon indicating copy to clipboard operation
long.js copied to clipboard

Issue when running build on a NodeJS app

Open VeniMitev opened this issue 2 years ago • 4 comments

Receiving the following error when running "npm run build" on a TypeScript NodeJS app:

node_modules/long/umd/index.d.ts:1:18 - error TS1479: 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.

1 import Long from "../index.js";

Following the error logs, it all comes to this package. I'm not sure which one of my packages uses "long"

VeniMitev avatar Nov 28 '23 21:11 VeniMitev

currently having the exact same issue. Related to https://github.com/dcodeIO/long.js/issues/125

japrescott avatar Dec 04 '23 14:12 japrescott

Having same issue, anyone find the solution ? Thanks

vivekjpatel avatar Dec 18 '23 10:12 vivekjpatel

I am facing the same issue

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.

it is being used by pnpm but I am not sure what's wrong

localhostd3veloper avatar Dec 30 '23 07:12 localhostd3veloper

@dcodeIO Is there any resolution in sight for this? The problem is inproper TypeScript types for long when using ESM.

philkunz avatar Jun 17 '24 12:06 philkunz