lightship
lightship copied to clipboard
CommonJS issue
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.
Same issue here! 🙃
Same here. Currently is not possible to use it with typescript or nestjs
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?
Just ran into this as well. Unable to use this in our environment :(
Just ran into this as well. Unable to use this in our environment :(
I use old version.
Just ran into this as well. Unable to use this in our environment :(
I use old version.
which one do you use?
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
I confirm [email protected]
is the latest version compatible with CJS