Skip to content

ReferenceError: __dirname is not defined in ES module scope #10

@pavelmickevic

Description

@pavelmickevic

Description

__dirname problem

Steps to reproduce

when running step:

            - name: Post stats
              uses: 'getoslash/github-build-stats-action@v1.0.1'
              with:
                  token: ${{ secrets.GITHUB_TOKEN }}
                  workflowId: ci.yaml
                  pullRequest: ${{ github.event.number }}

error is returned:

...
file:///location/_actions/getoslash/github-build-stats-action/v1.0.1/dist/index.js:9183
/******/ 	if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
         	                                                                         ^

ReferenceError: __dirname is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/location/_actions/getoslash/github-build-stats-action/v1.0.1/dist/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///location/_actions/getoslash/github-build-stats-action/v1.0.1/dist/index.js:9183:84
    at file:///location/_actions/getoslash/github-build-stats-action/v1.0.1/dist/index.js:9193:12
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Node.js v20.18.0

Additional Information

No response

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