Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module on local plugin #2483

Open
tlkiong opened this issue Dec 6, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@tlkiong
Copy link

tlkiong commented Dec 6, 2024

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
}
  1. 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:

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

@tlkiong tlkiong added the bug Something isn't working label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant