Skip to content

__dirname is not defined in ES module scope #282

@Chen-Michael

Description

@Chen-Michael

Is there anyone who can help integrate vite-plugin-electron with Playwright?
By default, vite-plugin-electron uses ES modules, and directly installing Playwright leads to the following error:

await playwright.chromium.launch()
App threw an error during load  
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 '/Users/mike/Documents/git/national-library-robot/package.json' contains "type": "module".  
To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

What can I do?

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