npmnpm-installhexo

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


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


Solution

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