使用nvm卸载node旧版本的时候碰到一个权限问题。

nvm卸载node权限问题
$ nvm uninstall 4.4.5 file is not writable: $NVM_DIR/versions/node/v4.4.5/bin/npm Cannot uninstall, incorrect permissions on installation folder. This is usually caused by running `npm install -g` as root. Run the following commands as root to fix the permissions and then try again. chown -R chenjiebin "$NVM_DIR/versions/node/v4.4.5" chmod -R u+w "$NVM_DIR/versions/node/v4.4.5"
大意是说有使用过root用户执行npm install -g命令,导致$NVM_DIR/versions/node/v4.4.5/bin/npm这个目录没有写权限,需要修改相应目录的权限。
尝试sudo卸载
改权限太麻烦了些,尝试sudo用root用户直接卸载。
$ sudo nvm uninstall 4.4.5 sudo: nvm: command not found
nvm不在sudo可执行命令,只能用修改对应目录权限的方法。
修改目录权限
查下 $NVM_DIR这个变量指向那个目录
$ echo $NVM_DIR /Users/chenjiebin/.nvm
确定OK,没有问题,下面开始修改权限
$ sudo chown -R chenjiebin "$NVM_DIR/versions/node/v4.4.5" $ sudo chmod -R u+w "$NVM_DIR/versions/node/v4.4.5"
再次卸载
$ nvm uninstall 4.4.5 Uninstalled node v4.4.5
成功
转载请注明:快乐编程 » nvm卸载node遇到的权限问题