You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of node v13.2, ES Modules are no longer hidden behind the --experimental-modules flag. When creating a project with "type":"module" in package.json and running mocha, the following error happens.
Warning: require() of ES modules is not supported.
require() of /path/to/componentTest.js from /path/to/node_modules/mocha/lib/mocha.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 componentTest.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /path/to/package.json.
/path/to/node_modules/mocha/lib/mocha.js:1
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /path/to/componentTest.js
The offending line being
at Mocha.loadFiles (/path/to/node_modules/mocha/lib/mocha.js:331:14)
It seems to me, either this is a fairly large oversight in mocha, or there's a lack of documentation for this issue (all I've found in google is a comment on a closed issue).
Node: v13.2.0
Mocha: v6.2.2
npm: v6.13.1
The text was updated successfully, but these errors were encountered:
As of node v13.2, ES Modules are no longer hidden behind the
--experimental-modules
flag. When creating a project with"type":"module"
in package.json and running mocha, the following error happens.The offending line being
It seems to me, either this is a fairly large oversight in mocha, or there's a lack of documentation for this issue (all I've found in google is a comment on a closed issue).
Node: v13.2.0
Mocha: v6.2.2
npm: v6.13.1
The text was updated successfully, but these errors were encountered: