-
-
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
Stopped working on Node.js v10.24: "Error: Not supported" caused by ESM import #4652
Comments
We dropped support of Node v10 in Mocha v9.0.0 as a breaking change. |
@juergba I understand that :) My point here is that if it was hard to backport the code to keep it working on Node 10, it would've been a fair deal to drop it completely and not accept any fixes. In this particular case though, it's just a matter of a small (and correct) fix which might keep the code working on the older versions for the time being. Of course we'll be able to pin our workflows to 8.x (since we do need to keep supporting Node 10 for a little bit longer), but - again - I personally don't like the idea of breaking the stuff that can still work. Up to you though :) |
@alexander-fenster I like clear cuts, but could live with your change. @giltayar cc |
I had this error on Node 12 :/ |
I am on Node You can see my migration to use back the module after upgrading to Mocha v9: sudo-bot/gh-deployer@3965e27
|
@williamdes this issue is about Mocha v9 and javascript. As far as I can see you have had your issue 12 days ago, at that time Mocha v9 hasn't been published yet. Edit: I recommend to pin your sindresorhus dependency to a version before pure ESM. Otherwise you will have to invest some time to get through this experimental esm-loader-story. It's not really fun. |
…y this ESM error does NOT pop up on the local (Windows) dev machines. ``` Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/circleci/project/test/test.js require() of ES modules is not supported. require() of /home/circleci/project/test/test.js from /home/circleci/project/node_modules/mocha/lib/esm-utils.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules. Instead rename test.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/circleci/project/package.json. at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13) at Module.load (internal/modules/cjs/loader.js:950:32) at Function.Module._load (internal/modules/cjs/loader.js:790:14) at Module.require (internal/modules/cjs/loader.js:974:19) at require (internal/modules/cjs/helpers.js:92:18) at Object.exports.requireOrImport (/home/circleci/project/node_modules/mocha/lib/esm-utils.js:54:18) at async Object.exports.loadFilesAsync (/home/circleci/project/node_modules/mocha/lib/esm-utils.js:73:20) at async singleRun (/home/circleci/project/node_modules/mocha/lib/cli/run-helpers.js:125:3) at async Object.exports.handler (/home/circleci/project/node_modules/mocha/lib/cli/run.js:366:5) make: *** [Makefile:35: test] Error 1 npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! @gerhobbelt/[email protected] test: `make test` npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the @gerhobbelt/[email protected] test script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /home/circleci/.npm/_logs/2021-07-01T12_52_07_807Z-debug.log ```
Prerequisites
faq
labelnode node_modules/.bin/mocha --version
(Local) andmocha --version
(Global). We recommend that you not install Mocha globally.Description
In
lib/esm-utils.js
,hasStableEsmImplementation
returnstrue
on Node.js v10.24.1 even though it must only returntrue
on versions >= 12.22.Steps to Reproduce
In the cloned
mocha
repository:Expected behavior: [What you expect to happen]
No error
Actual behavior: [What actually happens]
Reproduces how often: [What percentage of the time does it reproduce?]
100%
Versions
9.0.0
mocha --version
andnode node_modules/.bin/mocha --version
:node --version
:Additional Information
The text was updated successfully, but these errors were encountered: