Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonJS issue #69

Open
pauliusg opened this issue Jan 17, 2024 · 5 comments
Open

CommonJS issue #69

pauliusg opened this issue Jan 17, 2024 · 5 comments

Comments

@pauliusg
Copy link

pauliusg commented Jan 17, 2024

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 #67
But I think I have provided valuable information where the root cause is.

@mstroiu
Copy link

mstroiu commented Feb 2, 2024

Same issue here! 🙃

@dariusdev
Copy link

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

@djnym
Copy link

djnym commented Jun 18, 2024

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?

@maxwlang
Copy link

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

@pauliusg
Copy link
Author

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

I use old version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants