npm 源管理工具 nrm npm install -g nrm
全局安装后执行命令报错:
internal/validators.js:124 throw new ERR_INVALID_ARG_TYPE(name, 'string', value); ^ [TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined at validateString (internal/validators.js:124:11) at Object.join (path.js:424:7) at Object.<anonymous> (C:\Users\Deshun\AppData\Roaming\npm\node_modules\nrm\cli.js:17:20) at Module._compile (internal/modules/cjs/loader.js:1072:14) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) at Module.load (internal/modules/cjs/loader.js:937:32) at Function.Module._load (internal/modules/cjs/loader.js:778:12) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) at internal/main/run_main_module.js:17:47 ] { code: 'ERR_INVALID_ARG_TYPE' }
解决方法:
可以看到报错内容中有一个 cli.js
文件的第 17 行出现错误,按住 Ctrl + 鼠标点击,打开文件,将第 17 行修改一下:
// const NRMRC = path.join(process.env.HOME, '.nrmrc'); const NRMRC = path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], '.nrmrc');
再执行命令,就可以正常使用了。
未经允许不得转载:前端资源网 - w3h5 » npm源管理工具nrm报错:ERR_INVALID_ARG_TYPE解决