eslint-parallel icon indicating copy to clipboard operation
eslint-parallel copied to clipboard

v1.2.1: CLI throws with ERR_REQUIRE_ESM from strip-ansi

Open johnhunter opened this issue 3 years ago • 0 comments

Node: v14.16.1 eslint-parallel: 1.2.1

Caused by https://github.com/pgAdmin/eslint-parallel/pull/25

Running eslint-parallel src/app/ --ext js throws the following error:

internal/modules/cjs/loader.js:1080
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: node_modules/eslint-parallel/node_modules/strip-ansi/index.js
require() of ES modules is not supported.
require() of node_modules/eslint-parallel/node_modules/strip-ansi/index.js from node_modules/eslint-parallel/lib/formatter.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 index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from [...]/node_modules/eslint-parallel/node_modules/strip-ansi/package.json.

Looks like the babel transformed eslint-parallel lib/formatter.js uses require and the strip-ansi module setting forbids it.

johnhunter avatar Jul 13 '21 08:07 johnhunter