解决npm切换国内源-nrm ls 命令*不显示的问题

523 阅读1分钟

nrm ls

none.png

解决方案

进入本地全局包安装目录,例AppData/Roaming/npm/node_modules/nrm.

nrm目录下打开cli.js文件,找到211行代码,修改如下.


// fixed * no display issue.

// cli.js 211行原代码

if (hasOwnProperty(customRegistries, name) && (name in registries || customRegistries[name].registry === registry.registry)) {

            registry[FIELD_IS_CURRENT] = true;

            customRegistries[name] = registry;

        }

//cli.js 211行修改后 只需要把&&修改成||即可.

if (hasOwnProperty(customRegistries, name) || (name in registries || customRegistries[name].registry === registry.registry)) {

            registry[FIELD_IS_CURRENT] = true;

            customRegistries[name] = registry;

        }

//修复后先切换源
nrm use taobao
//再执行
nrm ls

block.png