1. nvm安装npm失败:

在nvm的安装目录下, 打开settings.txt(需要修改权限,默认普通用户不能修改):

1
2
3
4
root: D:\nvm
path: B:\nodejs
node_mirror: http://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/

主要是加后两行镜像, 前两行是我之前文件的默认内容

2. nrm报错(一般出现在windows下)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
C:\Users\fanqi>nrm
internal/validators.js:117
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:117:11)
at Object.join (path.js:375:7)
at Object.<anonymous> (D:\nvm\v12.16.3\node_modules\nrm\cli.js:17:20)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
] {
code: 'ERR_INVALID_ARG_TYPE'
}

解决方法, 找到node_modules/nrm下的cli.js, 找到第17行

1
2
3
# const NRMRC = path.join(process.env.HOME, '.nrmrc'); 修改为:
const NRMRC = path.join(process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'], '.nrmrc');
# 还是跨平台时的问题