我试过n latest
cp: cannot create directory '/usr/local/lib/node_modules': Permission denied
cp: cannot create regular file '/usr/local/bin/node': Permission denied
cp: cannot create symbolic link '/usr/local/bin/npm': Permission denied
cp: cannot create symbolic link '/usr/local/bin/npx': Permission denied
cp: cannot create directory '/usr/local/include/node': Permission denied
我已经制作了文件夹
sudo mkdir -p /usr/local/n && chown -R $(whoami) /usr/local/n/
我使用的是 Ubuntu 18.04。
使用须藤
sudo n latest
sudo: n: command not found
答案1
本文概述了您遇到的问题以及解决该问题的正确方法。您应该尽可能避免运行 sudo。
https://guillermo.at/update-node-proper-way
要更新你的 npm:
npm i -g n
N_PREFIX=$HOME/.local n latest
答案2
我解决了
sudo mkdir -p /usr/local/n && chown -R $(whoami) /usr/local/n/
和
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share