Error [ERR_REQUIRE_ESM]: Must use import to load ES Module when running Alex
adrhumphreys opened this issue · 2 comments
adrhumphreys commented
Subject of the issue
On a fresh install I'm getting these node issues with ES Imports, I haven't set up a config file and I can get these issues by creating a new repo
Your environment
- OS: OSX BigSur
- Packages:
"alex": "^9.1.0"
- Env: Node
v16.11.1
and Yarn1.22.5
Steps to reproduce
mkdir alex && cd alex
yarn init -y
- Add to
package.json
"scripts": {
"lint": "alex"
}
- Run
yarn lint
Expected behaviour
Linting occurs
Actual behaviour
I get this funky error
$ alex
/Users/username/Code/alex/node_modules/alex/cli.js:12
var mdx = require('remark-mdx')
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/username/Code/alex/node_modules/remark-mdx/index.js from /Users/username/Code/alex/node_modules/alex/cli.js not supported.
Instead change the require of index.js in /Users/username/Code/alex/node_modules/alex/cli.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/username/Code/alex/node_modules/alex/cli.js:12:11) {
code: 'ERR_REQUIRE_ESM'
}
error Command failed with exit code 1.
wooorm commented
Thanks for reporting. Could you verify that it’s now solved?