npm ERR! Cannot read properties of null (reading 'matches')

25.4k Views Asked by At

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 [email protected]
npm WARN   node_modules/.pnpm/[email protected]/node_modules/compression
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/.pnpm/[email protected]/node_modules/eslint
npm WARN   dev eslint@"^5.16.0" from [email protected]
npm WARN   node_modules/.pnpm/[email protected]/node_modules/cross-spawn
npm WARN     [email protected]
npm WARN     node_modules/.pnpm/[email protected]/node_modules/cross-spawn
npm WARN     [email protected]
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 [email protected]
npm WARN node_modules/.pnpm/[email protected]/node_modules/babel-eslint
npm WARN   babel-eslint@"^11.0.0-beta.0" from [email protected]
npm WARN   node_modules/.pnpm/[email protected]/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

5

There are 5 best solutions below

0
yaoyhu On BEST ANSWER

This issue can be potentially resolved through two approaches for two kinds of people:

For people suffering network restrictions

Same here (Blocked by GFW by our gov).
Just use cnpm. I got same errors even though I have a proxy or 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.

For people with free access to real Network

The Highest score answered by gilly3 might be viable.

1
gilly3 On

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.

0
Javier Gutiérrez On

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.

1
user1874527 On

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

0
Damian Green On

In my scenario I was actually using pnpm as my package manager but had erroneously typed npm i.

So the solution is to just run pnpm i instead.

Not the clearest of error messages..