Error [ERR_REQUIRE_ESM]: Must use import to load ES Module on local plugin
- Dominant language
- TypeScript
- Stars
- 2.5k
- Forks
- 221
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Seems to be unable to load ESM for a local plugin.
**To Reproduce**
1. Create a file at `.auto/plugins/test.ts`
2. add `console.log('Works')` in `tests.ts` file
3. In `.autorc`, do the following
```
{
"plugins": [
... // other plugins
"./.auto/plugins/test.ts"
],
// other config
}
```
4. Run `yarn auto shipit -d`
output:
> Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/tlkiong/Desktop/work/test/.auto/plugins/test.ts
require() of ES modules is not supported.
require() of /Users/tlkiong/Desktop/work/test/.auto/plugins/commit-sha.ts from /Users/tlkiong/Desktop/work/test/node_modules/import-from/index.js is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from /Users/tlkiong/Desktop/work/test/package.json.
And yes, I have `"type": "module",` in my `package.json`
**Expected behavior**
**Screenshots**
**Environment information:**
```txt
Environment Information:
"auto" version: v11.2.0
"git" version: v2.40.0
"node" version: v22.2.0
Project Information:
✔ Repository: ~
✔ Author Name: tlkiong
✔ Author Email: ~
✔ Current Version: v1.109.0
✔ Latest Release: v1.109.0
✖ Labels configured on GitHub project (Try running "auto create-labels")
GitHub Token Information:
✔ Token: [Token starting with ghp_]
✔ Repo Permission: admin
✔ User: tlkiong
✔ API:
✔ Enabled Scopes: repo, workflow, write:packages
✔ Rate Limit: 4997/5000
```
**Additional context**
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.