Cannot read properties of null (reading ‘pickAlgorithm‘)

今日在安装一个项目的依赖时,提示Cannot read properties of null (reading 'pickAlgorithm')

再网上查了资料都说使用npm cache clear --force, 然而效果不是很好,并且在mac上还需要使用sudo npm cache clear --force才能清除。

后查看npm的debug日志

8920 timing command:install Completed in 399063ms
8921 verbose stack TypeError: Cannot read properties of null (reading 'pickAlgorithm')
8921 verbose stack     at Integrity.match (/usr/local/lib/node_modules/npm/node_modules/ssri/index.js:234:24)
8921 verbose stack     at CachePolicy.satisfies (/usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/lib/cache/policy.js:113:49)
8921 verbose stack     at Function.find (/usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/lib/cache/entry.js:172:25)
8921 verbose stack     at async cacheFetch (/usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/lib/cache/index.js:8:17)
8921 verbose stack     at async fetch (/usr/local/lib/node_modules/npm/node_modules/make-fetch-happen/lib/fetch.js:82:7)
8922 verbose cwd /Volumes/frontend
8923 verbose Darwin 21.5.0
8924 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
8925 verbose node v16.11.0
8926 verbose npm  v8.0.0
8927 error Cannot read properties of null (reading 'pickAlgorithm')
8928 verbose exit 1

错误没看懂是啥地方报的,然后向上翻几页,发现了一个404

8840 http fetch POST 404 https://registry.npmmirror.com/-/npm/v1/security/audits/quick 1531ms (cache skip)
8841 verbose audit error HttpErrorGeneral: 404 Not Found - POST https://registry.npmmirror.com/-/npm/v1/security/audits/quick
8841 verbose audit error     at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:95:15
8841 verbose audit error     at processTicksAndRejections (node:internal/process/task_queues:96:5)
8841 verbose audit error     at async Map.[getReport] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:337:21)
8841 verbose audit error     at async Map.run (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:107:19)
8841 verbose audit error  HttpErrorGeneral: 404 Not Found - POST https://registry.npmmirror.com/-/npm/v1/security/audits/quick
8841 verbose audit error     at /usr/local/lib/node_modules/npm/node_modules/npm-registry-fetch/check-response.js:95:15
8841 verbose audit error     at processTicksAndRejections (node:internal/process/task_queues:96:5)
8841 verbose audit error     at async Map.[getReport] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:337:21)
8841 verbose audit error     at async Map.run (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/audit-report.js:107:19) {
8841 verbose audit error   headers: [Object: null prototype] {
8841 verbose audit error     server: [ 'Tengine' ],
8841 verbose audit error     'content-type': [ 'text/html; charset=utf-8' ],
8841 verbose audit error     'content-length': [ '41' ],
8841 verbose audit error     connection: [ 'keep-alive' ],
8841 verbose audit error     'strict-transport-security': [ 'max-age=5184000' ],
8841 verbose audit error     date: [ 'Fri, 02 Dec 2022 07:50:49 GMT' ],
8841 verbose audit error     vary: [ 'Origin' ],
8841 verbose audit error     'x-frame-options': [ 'SAMEORIGIN' ],
8841 verbose audit error     'x-xss-protection': [ '1; mode=block' ],
8841 verbose audit error     'x-content-type-options': [ 'nosniff' ],
8841 verbose audit error     'x-download-options': [ 'noopen' ],
8841 verbose audit error     'x-readtime': [ '1.72' ],
8841 verbose audit error     'content-encoding': [ 'gzip' ],
8841 verbose audit error     'ali-swift-global-savetime': [ '1669967449' ],
8841 verbose audit error     via: [
8841 verbose audit error       'cache11.l2hk3[314,313,404-1280,M], cache29.l2hk3[315,0], cache17.hk6[317,317,404-1280,M], cache14.hk6[319,0]'
8841 verbose audit error     ],
8841 verbose audit error     'x-cache': [ 'MISS TCP_MISS dirn:-2:-2' ],
8841 verbose audit error     'x-swift-savetime': [ 'Fri, 02 Dec 2022 07:50:49 GMT' ],
8841 verbose audit error     'x-swift-cachetime': [ '1' ],
8841 verbose audit error     'x-swift-error': [ 'orig response 4XX error' ],
8841 verbose audit error     'timing-allow-origin': [ '*' ],
8841 verbose audit error     eagleid: [ '2ff6109216699674490792554e' ],
8841 verbose audit error     'x-fetch-attempts': [ '1' ],
8841 verbose audit error     'x-local-cache-status': [ 'skip' ]
8841 verbose audit error   },
8841 verbose audit error   statusCode: 404,
8841 verbose audit error   code: 'E404',
8841 verbose audit error   method: 'POST',
8841 verbose audit error   uri: 'https://registry.npmmirror.com/-/npm/v1/security/audits/quick',
8841 verbose audit error   body: <Buffer 3c 68 31 3e 34 30 34 20 4e 6f 74 20 46 6f 75 6e 64 3c 2f 68 31 3e>,
8841 verbose audit error   pkgid: undefined
8841 verbose audit error }
8842 silly audit error <h1>404 Not Found</h1>

意思是说镜像获取不到,输入命令npm config get registry,查看当前npm镜像源,是taobao的,切换回默认的试试看。npm config delete registry

重新执行npm install,完美~

你可能感兴趣的:(笔记,npm,前端,javascript)