isaacs / minimatch

a glob matcher in javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: better ESM compatibility

JounQin opened this issue · comments

import { Minimatch } from 'minimatch';

new Minimatch(pattern) // fail
import { Minimatch } from 'minimatch';
         ^^^^^^^^^
SyntaxError: Named export 'Minimatch' not found. The requested module 'minimatch' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'minimatch';
const { Minimatch } = pkg;

What version are you using? This works fine in the latest release.

Run npm ls minimatch and paste the results here.

OK, it seems there are many conflict minimatch installed.

eslint-sonarjs@0.0.0 /Users/JounQin/Workspaces/GitHub/eslint-plugin-sonar
├─┬ @1stg/common-config@9.0.1
│ ├─┬ @1stg/commitlint-config@3.2.0
│ │ └─┬ @commitlint/config-lerna-scopes@17.8.1
│ │   └─┬ glob@8.1.0
│ │     └── minimatch@5.1.6
│ ├─┬ @1stg/eslint-config@7.0.1
│ │ └─┬ eslint-plugin-n@16.5.0
│ │   └── minimatch@3.1.2 deduped
│ ├─┬ @1stg/markuplint-config@3.0.1
│ │ └─┬ markuplint@3.15.0
│ │   ├─┬ @markuplint/create-rule-helper@3.15.0
│ │   │ └─┬ glob@10.3.10
│ │   │   └── minimatch@9.0.3
│ │   └─┬ @markuplint/file-resolver@3.15.0
│ │     ├─┬ glob@10.3.10
│ │     │ └── minimatch@9.0.3 deduped
│ │     └── minimatch@9.0.3
│ ├─┬ @1stg/remark-preset@2.0.0
│ │ └─┬ remark-validate-links@12.1.1
│ │   └─┬ unified-engine@10.1.0
│ │     ├─┬ glob@8.1.0
│ │     │ └── minimatch@5.1.6
│ │     └─┬ load-plugin@5.1.0
│ │       └─┬ @npmcli/config@6.4.0
│ │         └─┬ @npmcli/map-workspaces@3.0.4
│ │           ├─┬ glob@10.3.10
│ │           │ └── minimatch@9.0.3 deduped
│ │           └── minimatch@9.0.3
│ ├─┬ eslint@8.56.0 invalid: "8.55.0" from SonarJS
│ │ ├─┬ @eslint/eslintrc@2.1.4
│ │ │ └── minimatch@3.1.2 deduped
│ │ ├─┬ @humanwhocodes/config-array@0.11.13
│ │ │ └── minimatch@3.1.2 deduped
│ │ └── minimatch@3.1.2
│ └─┬ npm-run-all@4.1.5
│   └── minimatch@3.1.2 deduped
├─┬ eslint-plugin-sonar@0.13.0 -> ./eslint-plugin-sonar
│ ├─┬ @typescript-eslint/parser@6.16.0 invalid: "6.14.0" from SonarJS, "^5.60.0" from node_modules/@1stg/eslint-config
│ │ └─┬ @typescript-eslint/typescript-estree@6.16.0
│ │   └── minimatch@9.0.3
│ ├─┬ eslint-plugin-jsx-a11y@6.8.0
│ │ └── minimatch@3.1.2 deduped
│ ├─┬ eslint-plugin-react@7.33.2
│ │ └── minimatch@3.1.2 deduped
│ └── minimatch@9.0.3
├─┬ patch-package@8.0.0
│ └─┬ rimraf@2.7.1
│   └─┬ glob@7.2.3
│     └── minimatch@3.1.2 deduped
├─┬ sonarjs@1.0.0 -> ./SonarJS
│ ├─┬ eslint-plugin-import@npm:eslint-plugin-i@2.29.1 invalid: "2.29.0" from SonarJS
│ │ └── minimatch@3.1.2 deduped
│ ├── minimatch@9.0.3
│ ├─┬ pretty-quick@3.1.3
│ │ └─┬ multimatch@4.0.0
│ │   └── minimatch@3.1.2 deduped
│ ├─┬ ts-jest@29.1.1
│ │ └─┬ babel-jest@29.7.0
│ │   └─┬ babel-plugin-istanbul@6.1.1
│ │     └─┬ test-exclude@6.0.0
│ │       └── minimatch@3.1.2 deduped
│ └─┬ typedoc@0.25.4
│   └── minimatch@9.0.3
└─┬ type-coverage@2.27.1
  └─┬ type-coverage-core@2.27.1
    └── minimatch@9.0.3