Closed swarnadeepsaha closed 1 year ago
Also having this issue
Same here.
same problem here
fixed in v9.0.1
Same problem :
Error [ERR_REQUIRE_ESM]: require() of ES Module xxx/nodejs/kube-collector/node_modules/lightship/dist/cjs/index.js from xxx/xxx/xxx.js not supported.
Instead change the require of index.js in xxx/xxx/xxx.js to a dynamic import() which is available in all CommonJS modules.
Edit, I fix the problem :
In 7.2, I have this code :
const { createLightship } = require('lightship');
module.exports = async () => {
const lightship = await createLightship({
detectKubernetes : process.env.NODE_ENV === 'production',
// gracefulShutdownTimeout : 1000 * 60,
// shutdownHandlerTimeout : 1000 * 60,
});
/* istanbul ignore next */
lightship.queueBlockingTask(new Promise((resolve) => {
setTimeout(() => {
// Lightship service status will be `SERVER_IS_NOT_READY` until all promises
// submitted to `queueBlockingTask` are resolved.
resolve();
}, 1000);
}));
return lightship;
};
In 9.0.1 I change to that, and it works fine :
module.exports = async () => {
const { createLightship } = await import('lightship');
const lightship = await createLightship({
detectKubernetes : process.env.NODE_ENV === 'production',
// gracefulShutdownTimeout : 1000 * 60,
// shutdownHandlerTimeout : 1000 * 60,
});
/* istanbul ignore next */
lightship.queueBlockingTask(new Promise((resolve) => {
setTimeout(() => {
// Lightship service status will be `SERVER_IS_NOT_READY` until all promises
// submitted to `queueBlockingTask` are resolved.
resolve();
}, 1000);
}));
return lightship;
};
(In my case, I used an abstraction method to simplify usage if lightship have any major change in the future)
after
8.0.0
is not able to use in the CJS project reason it has no export definition for CJSrequire
. not able to move beyond7
.Issue: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /usr/app/bin/node_modules/lightship/package.json
Please add a build for CJS too and redefine the export similarly to