Skip to content

__filename is not defined (ESM) #703

@iDVB

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions