lightship icon indicating copy to clipboard operation
lightship copied to clipboard

CommonJS issue

Open pauliusg opened this issue 1 year ago • 7 comments

As I understand lightship library is distributed as es and commonjs module: However it has dependency serialize-error ^11.0.0 which from v9 has breaking change and is pure es module: https://github.com/sindresorhus/serialize-error/releases/tag/v9.0.0

So looks like now lightship does not support commonjs?

UPDATE: In my project I get error:

Error [ERR_REQUIRE_ESM]: require() of ES Module ...\node_modules\lightship\dist\cjs\index.js from ...\SignalingAdapter.js not supported.
index.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead either rename index.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in ...\node_modules\lightship\package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

I can run newest version of lightship only with some hacks. In my project package.json I added (then npm overrides version of lib):

  "overrides": {
    "serialize-error": "^8.1.0"
  }

Additionally I had to make manual edit in installed lightship ...\node_modules\lightship\package.json to remove line:

  "type": "module",

But this workaround is not acceptable in prod environment :)

UPDATE2: seems that my issue is duplicate of https://github.com/gajus/lightship/issues/67 But I think I have provided valuable information where the root cause is.

pauliusg avatar Jan 17 '24 14:01 pauliusg

Same issue here! 🙃

mstroiu avatar Feb 02 '24 07:02 mstroiu

Same here. Currently is not possible to use it with typescript or nestjs

dariusdev avatar Mar 22 '24 14:03 dariusdev

I see something was attempted last year to fix this, but as this is still happening any idea when it might be addressed? Is this project still active?

djnym avatar Jun 18 '24 17:06 djnym

Just ran into this as well. Unable to use this in our environment :(

maxwlang avatar Jul 11 '24 21:07 maxwlang

Just ran into this as well. Unable to use this in our environment :(

I use old version.

pauliusg avatar Jul 11 '24 21:07 pauliusg

Just ran into this as well. Unable to use this in our environment :(

I use old version.

which one do you use?

fiedler-itlabs avatar Jul 16 '24 06:07 fiedler-itlabs

Just ran into this as well. Unable to use this in our environment :(

I use old version.

which one do you use?

v7.2.0

pauliusg avatar Jul 16 '24 06:07 pauliusg

I confirm [email protected] is the latest version compatible with CJS

Kikobeats avatar Oct 18 '24 15:10 Kikobeats