Skip to content

__filename is not defined (ESM) #703

Description

@iDVB

Package doesn't support ESM?

ReferenceError: __filename is not defined

node_modules/.pnpm/@contentful+node-apps-toolkit@2.8.2/node_modules/@contentful/node-apps-toolkit/lib/keys/get-management-token.js102:179
        defaultCache = new NodeCache();
    }
    const httpClientOpts = typeof opts.host !== 'undefined' ? { prefixUrl: opts.host } : {};
    return (0, exports.createGetManagementToken)((0, utils_1.createLogger)({ filename: __filename }), (0, utils_1.createHttpClient)(httpClientOpts), defaultCache)(privateKey, opts);
};
exports.getManagementToken = getManagementToken;

Should likely has an ESM supported build?

// Import the URL module to resolve file paths
import { fileURLToPath } from 'url'

// ESM replacement for __filename
const __filename = fileURLToPath(import.meta.url)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions