|
return new (require(moduleName).Agent)({ keepAlive: true }); |
ReferenceError: require is not defined
at createKeepAliveAgent (file:///Users/nolan/Documents/my-app/node_modules/@contentstack/core/dist/esm/src/lib/contentstack-core.js:11:5)
at httpClient (file:///Users/nolan/Documents/my-app/node_modules/@contentstack/core/dist/esm/src/lib/contentstack-core.js:20:20)
at Module.stack (file:///Users/nolan/Documents/my-app/node_modules/@contentstack/delivery-sdk/dist/modern/stack/contentstack.js:61:18)
The only way I can solve this is shimming app start up before contentstack initialization happens.
import {createRequire} from 'module';
if (typeof globalThis.require === 'undefined') {
globalThis.require = createRequire(import.meta.url);
}
Version Info:
- @contentstack/delivery-sdk@5.5.1
- @contentstack/core@1.5.0
- @contentstack/utils@1.9.1
- Node 22.22.0 and Node 24.19.0
Not that it might be as relevant, this also happens in the @contentstack/delivery-sdk@4.12.1.
contentstack-js-core/src/lib/contentstack-core.ts
Line 15 in 124b694
ReferenceError: require is not defined at createKeepAliveAgent (file:///Users/nolan/Documents/my-app/node_modules/@contentstack/core/dist/esm/src/lib/contentstack-core.js:11:5) at httpClient (file:///Users/nolan/Documents/my-app/node_modules/@contentstack/core/dist/esm/src/lib/contentstack-core.js:20:20) at Module.stack (file:///Users/nolan/Documents/my-app/node_modules/@contentstack/delivery-sdk/dist/modern/stack/contentstack.js:61:18)The only way I can solve this is shimming app start up before contentstack initialization happens.
Version Info:
Not that it might be as relevant, this also happens in the @contentstack/delivery-sdk@4.12.1.