我知道我不应该,但我做了“sudo npm" [英] I know I shoulnd'nt, but I did 'sudo npm'
问题描述
当我尝试
npm install -g npm
npm install -g npm
有很多警告
所以我做了
sudo npm install -g npm
sudo npm install -g npm
这似乎完美无缺.
但是现在,当我想在终端中使用 npm 时,它会返回:
however now, when I want to use npm in terminal it returns:
bash: npm: 命令未找到
bash: npm: command not found
我现在只能通过 sudo 使用 npm.
I can only use npm with sudo now.
我该如何还原?
我尝试重新安装 npm 和 nodejs但它不起作用.
I tried reinstalling npm and nodejs but it does not work.
顺便说一句,我正在运行 arch linux
I am running arch linux btw
推荐答案
我建议你先卸载 Node 和 npm.然后安装 NVM.这样,您就不会面临权限问题,同时您可以拥有多个版本的 Node(如果需要).在系统上安装 NVM 后,您可以使用以下 command 安装最新版本的 Node.
I would suggest you to first uninstall Node and npm. Then install the NVM. In this way, you'll not face the permission issue and at the same time you can have multiple version of Node (if needed). Once you have NVM on your system you can use following command to install latest version of Node.
nvm install node
这篇关于我知道我不应该,但我做了“sudo npm"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!