12

After I installed hexo, I used npm install to complete the packages in package.json, but he reported an error, the content of the error is as follows ❯ node --version v18.12.1 ❯ npm --version 9.1.3

❯ npm install

············

npm WARN   dev eslint-config-standard@"12.0.0" from compression@1.7.4
npm WARN   node_modules/.pnpm/compression@1.7.4/node_modules/compression
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: babel-eslint@11.0.0-beta.2
npm WARN Found: eslint@5.16.0
npm WARN node_modules/.pnpm/cross-spawn@7.0.3/node_modules/eslint
npm WARN   dev eslint@"^5.16.0" from cross-spawn@7.0.3
npm WARN   node_modules/.pnpm/cross-spawn@7.0.3/node_modules/cross-spawn
npm WARN     cross-spawn@7.0.3
npm WARN     node_modules/.pnpm/hexo-util@2.7.0/node_modules/cross-spawn
npm WARN     cross-spawn@7.0.3
npm WARN     node_modules/.pnpm/node_modules/cross-spawn
npm WARN   4 more (eslint-config-moxy, eslint-plugin-babel, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@">= 6.0.0" from babel-eslint@11.0.0-beta.2
npm WARN node_modules/.pnpm/cross-spawn@7.0.3/node_modules/babel-eslint
npm WARN   babel-eslint@"^11.0.0-beta.0" from eslint-config-moxy@7.1.0
npm WARN   node_modules/.pnpm/cross-spawn@7.0.3/node_modules/eslint-config-moxy
npm ERR! Cannot read properties of null (reading 'matches')

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/zhangyun/.npm/_logs/2022-12-02T01_51_51_393Z-debug-0.log

I tried running npm cache clear --force, or changing the npm mirror, but that didn't work

Sam Ma
  • 121
  • 1
  • 4
  • 5
    try deleting the node module folder and running the command again, eslint@">= 6.0.0" this tho is the package that gives the problem – Skin_phil Dec 02 '22 at 15:48
  • upstream issue: [\[BUG\] npm link : Cannot read properties of null (reading 'matches')](https://github.com/npm/cli/issues/4367) – milahu Aug 11 '23 at 08:28

4 Answers4

21

This error shows up when you run npm install in a directory where you previously ran pnpm install. The solution is to remove your node_modules directory and run npm install again.

gilly3
  • 87,962
  • 25
  • 144
  • 176
  • Also happens if you run `npm uninstall` in the same directory where you previously ran `pnpm install` – kevlarr Jun 07 '23 at 18:51
1

After trying all these solutions, had the idea to use a different network adapter (android phone tether, as i was on wifi). The phone is connected to exactly the same wifi network, but now pnpm and npm came back to life again just like that. So for me it was somehow a network adapter related issue.

0

Same here (Blocked by GFW by our gov).
Just use cnpm. I got this bug even though I have a proxy and set mirror to taobao.com.

// use mirror to install
npm install -g cnpm --registry=https://registry.npm.taobao.org

Then install using cnpm install which works for me.

Daniel Hu
  • 31
  • 1
  • 5
0

If you are using pnpm, stick to that and do not use npm

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 12 '23 at 08:22