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

5

38

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

Analysand answered 2/12, 2022 at 2:18 Comment(2)
try deleting the node module folder and running the command again, eslint@">= 6.0.0" this tho is the package that gives the problemNotate
upstream issue: [BUG] npm link <package>: Cannot read properties of null (reading 'matches')Supererogate
R
-4

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

For people suffering the Network restrictions

If you got blocked by GFW by 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

Remove your node_modules directory and run npm install again. See the Highest score answered by gilly3.

Reliquary answered 28/3, 2023 at 11:16 Comment(0)
A
94

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.

Anissa answered 7/6, 2023 at 15:53 Comment(1)
Also happens if you run npm uninstall in the same directory where you previously ran pnpm installDe
W
14

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

Walt answered 8/8, 2023 at 2:28 Comment(1)
it worked for me!Older
P
7

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..

Pintail answered 28/3 at 10:32 Comment(0)
C
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.

Clambake answered 10/6, 2023 at 17:46 Comment(0)
R
-4

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

For people suffering the Network restrictions

If you got blocked by GFW by 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

Remove your node_modules directory and run npm install again. See the Highest score answered by gilly3.

Reliquary answered 28/3, 2023 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.