nrm报错

报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
internal/validators.js:112
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^

[TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
at validateString (internal/validators.js:112:11)
at Object.join (path.js:375:7)
at Object.<anonymous> (C:\Users\wy\AppData\Roaming\npm\node_modules\nrm\cli.js:17:20)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11
] {
code: 'ERR_INVALID_ARG_TYPE'
}

解决

找到nrm安装位置,打开cli.js修改第17行

windows下目录在C:\Users\用户名\AppData\Roaming\npm\node_modules\nrm\

1
2
//const NRMRC = path.join(process.env.HOME, '.nrmrc'); (删除)
const NRMRC = path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], '.nrmrc');