diff --git a/gax/esm/src/fallbackServiceStub.ts b/gax/esm/src/fallbackServiceStub.ts index bec89b47b..c87271130 100644 --- a/gax/esm/src/fallbackServiceStub.ts +++ b/gax/esm/src/fallbackServiceStub.ts @@ -42,7 +42,12 @@ export interface FallbackServiceStub { export type FetchParametersMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'; async function getNodeFetch() { - return await import('node-fetch'); + const isEsm = true; + if (isEsm) { + return await import('node-fetch'); + } else { + return require('node-fetch'); + } } export interface FetchParameters { headers: {[key: string]: string}; diff --git a/gax/package.json b/gax/package.json index ba855af14..25619ea2a 100644 --- a/gax/package.json +++ b/gax/package.json @@ -2,9 +2,9 @@ "name": "google-gax", "version": "4.5.0", "description": "Google API Extensions", - "main": "./build/cjs/src/index.cjs", + "main": "./build/esm/src/index.js", "type": "module", - "types": "./build/cjs/src/index.d.ts", + "types": "./build/esm/src/index.d.ts", "files": [ "build/esm", "build/cjs",