1987WEB视界-分享互联网热点话题和事件

您现在的位置是:首页 > WEB开发 > 正文

WEB开发

解决npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)

1987web2024-03-25WEB开发40
解决npmERR!Cannotreadpropertiesofnull(reading‘pickAlgorithm‘)

解决npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)

1. 复现问题

今天准备克隆Redis桌面(GUI)管理客户端,故按照官方文档给出的指令运行时,如下图所示:

但在执行指令npm install --platform=win32却报出如下图错误:

PS D:\Software\RedisDesktopManager\AnotherRedisDesktopManager>npminstall--platform=win32npmWARN configglobal`--global`,`--local`are deprecated.Use`--location=global`instead.npmWARN deprecated chokidar@2.1.8:Chokidar2doesnotreceive security updates since2019.Upgradeto chokidar3with15xfewer dependenciesnpmWARN deprecated chokidar@2.1.8:Chokidar2doesnotreceive security updates since2019.Upgradeto chokidar3with15xfewer dependenciesnpmWARN deprecated stable@0.1.8:ModernJS already guaranteesArray#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibilitynpmWARN deprecated electron-osx-sign@0.5.0:Pleaseuse@electron/osx-sign moving forward.Beaware the APIisslightly differentnpmWARN deprecated querystring@0.2.0:Thequerystring APIisconsideredLegacy.newcode shouldusetheURLSearchParamsAPI instead.npmWARN deprecated uuid@3.4.0:Pleaseupgrade to version7orhigher.Olderversions mayuseMath.random()incertain circumstances,whichisknown to be problematic.Seehttps://v8.dev/blog/math-randomfordetails.npmWARN deprecated debug@4.1.1:Debugversions>=3.2.0<3.2.7||>=4<4.3.1have a low-severityReDosregressionwhenusedinaNode.js environment.Itisrecommended you upgrade to3.2.7or4.3.1.(https://github.com/visionmedia/debug/issues/797)npmWARN deprecated browserslist@1.7.7:Browserslist2could fail on readingBrowserslist>3.0config usedinother tools.npmWARN deprecated browserslist@1.7.7:Browserslist2could fail on readingBrowserslist>3.0config usedinother tools.npmWARN deprecated browserslist@1.7.7:Browserslist2could fail on readingBrowserslist>3.0config usedinother tools.npmWARN deprecated svgo@0.7.2:ThisSVGO versionisnolonger supported.Upgradeto v2.x.x.npmWARN deprecated debug@4.1.1:Debugversions>=3.2.0<3.2.7||>=4<4.3.1have a low-severityReDosregressionwhenusedinaNode.js environment.Itisrecommended you upgrade to3.2.7or4.3.1.(https://github.com/visionmedia/debug/issues/797)npmWARN deprecated svgo@1.3.2:ThisSVGO versionisnolonger supported.Upgradeto v2.x.x.npmERR!Cannotreadproperties ofnull(readingpickAlgorithm)npmERR!A complete log ofthisrun can be foundin:npmERR!C:\Users\zxy\AppData\Local\npm-cache\_logs\2022-11-04T07_24_57_963Z-debug-0.log

注意看上述错误的倒数第3行,即Cannot read properties of null (reading pickAlgorithm)

2. 分析问题

Cannot read properties of null (reading pickAlgorithm)翻译成中文就是无法读取 null 的属性(读取 pickAlgorithm)

但是,我在运行指令npm install --platform=win32时,并没有涉及pickAlgorithm字段呀,于是,通过查找资料可得如下解决方案:

方案1

重新安装node解决,这并没有解决我的问题,舍弃。

方案2

删了node models重新下。

或者直接下载CNPM(淘宝镜像)进行安装CNPM安装办法:

npminstall-g cnpm-registry=https://registry.npm.taobao.org

查看cnpm是否真安装成功:

cnpm-v

这种方式也没有解决我的问题。

于是,使用如下第3种方案解决了我的问题。

3. 解决问题

在终端输入指令npm cache clear --force,如下所示:PS D:\Software\RedisDesktopManager\AnotherRedisDesktopManager>npmcacheclear--forcenpmWARN configglobal`--global`,`--local`are deprecated.Use`--location=global`instead.npmWARNusing--forceRecommendedprotections disabled.再次执行指令npm install --platform=win32,即可完成安装,如下所示:PS D:\Software\RedisDesktopManager\AnotherRedisDesktopManager>npminstall--platform=win32npmWARN configglobal`--global`,`--local`are deprecated.Use`--location=global`instead.npmWARN deprecated uuid@3.4.0:Pleaseupgrade to version7orhigher.Olderversions mayuseMath.random()incertain circumstances,whichisknown to be problematic.Seehttps://v8.dev/blog/math-randomfordetails.npmWARN deprecated browserslist@2.11.3:Browserslist2could fail on readingBrowserslist>3.0config usedinother tools.npmWARN deprecated debug@4.1.1:Debugversions>=3.2.0<3.2.7||>=4<4.3.1have a low-severityReDosregressionwhenusedinaNode.js environment.Itisrecommended you upgrade to3.2.7or4.3.1.(https://github.com/visionmedia/debug/issues/797)npmWARN deprecated uuid@3.3.2:Pleaseupgrade to version7orhigher.Olderversions mayuseMath.random()incertain circumstances,whichisknown to be problematic.Seehttps://v8.dev/blog/math-randomfordetails.npmWARN deprecated electron-osx-sign@0.5.0:Pleaseuse@electron/osx-sign moving forward.Beaware the APIisslightly differentnpmWARN deprecated svgo@0.7.2:ThisSVGO versionisnolonger supported.Upgradeto v2.x.x.npmWARN deprecated browserslist@1.7.7:Browserslist2could fail on readingBrowserslist>3.0config usedinother tools.npmWARN deprecated chokidar@2.1.8:Chokidar2doesnotreceive security updates since2019.Upgradeto chokidar3with15xfewer dependenciesnpmWARN deprecated browserslist@1.7.7:Browserslist2could fail on readingBrowserslist>3.0config usedinother tools.npmWARN deprecated browserslist@1.7.7:Browserslist2could fail on readingBrowserslist>3.0config usedinother tools.npmWARN deprecated svgo@1.3.2:ThisSVGO versionisnolonger supported.Upgradeto v2.x.x.added706packages,andchanged55packagesin2m93packages are lookingforfundingrun`npmfund`fordetails输入npm start启动程序,如下图所示:

此时,报出另外一个错误,即Cannot find module D:\Software\RedisDesktopManager\AnotherRedisDesktopManager\node_modules\fs.realpath\index.js. Please verify that the package.json has a valid "main" entry。

即在当前目录下找不到index.js文件,于是,我们去当前目录下区创建该文件即可:

创建index.js文件后,再次执行npm start指令,即可启动程序了,如下所示:

声明:本站所有文章,如无特殊说明或标注,均为爬虫抓取以及网友投稿,版权归原作者所有。