yargs-2302-build-with-vite
Background
I'm using Vite to bundle my pure ESM application (It's a CLI tool). After the cli tool is bundled, there is an error when executing the CLI
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and 'package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
How to reproduce
Run the following commands:
npm install
npm run build
./cli.js