-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Misleading ERR_REQUIRE_CYCLE_MODULE when attempting to import from module if module was never installed #5290
Comments
👍 thanks for the report! Confirmed, I can reproduce this locally. I pushed up my repro here: https://github.com/JoshuaKGoldberg/repros/tree/mocha-missing-module-cyclic On macOS with Node
On macOS with Node
I did a quick search for the error in the Node issue tracker and found:
nodejs/node#55516 looks like it might have links to a similar bug that was fixed in other libraries. Investigation required. |
…chajs#5290) Use require to handle both ESM and CJS in the latest Node.js due to loadESMFromCJS function.
Bug Report Checklist
faq
label, but none matched my issue.Expected
I forgot to npm install a library, and tried to test with Mocha. I expected an error about the missing module.
Actual
The error claims the missing module is a cyclical import. It is not cyclical, it is just missing
Minimal, Reproducible Example
Here is a gist that reproduces the problem using bash: https://gist.github.com/MaxKessler5/9d53a143df67ce1cd4dff9e9f03d2db4
The contents:
npm init -y
sed -i 's/"type": "commonjs"/"type": "module"/' package.json
echo "// Entry point for the application" > index.js
echo "import { cloneDeep } from "lodash-es";" >> index.js
sed -i 's/"test":.*/"test": "mocha"/' package.json
npm install mocha
mkdir test
echo "import "../index.js";" > test/test.js
npm test > output.txt
Versions
$ npx mocha --version
11.1.0
node_modules/.bin/mocha --version
(I'm on windows, not sure how to do this one)
node --version
v22.12.0
Additional Info
No response
The text was updated successfully, but these errors were encountered: