Jac*_*_Hu 10 upgrade apt curl nodejs 15.04
我无法更新 nodejs,我不明白为什么。
如果让我猜一下,我会说我在 apt-get 中列出了两个存储库,它们都包含一个 nodejs 包。
这是我所做的:
删除旧版本:
sudo apt-get remove --purge nodejs npm
Run Code Online (Sandbox Code Playgroud)
然后,通过https://github.com/nodesource/distributions#installation-instructions,我运行了:
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
Run Code Online (Sandbox Code Playgroud)
进而:
sudo apt-get install -y nodejs
Run Code Online (Sandbox Code Playgroud)
然后我运行:
nodejs -v
Run Code Online (Sandbox Code Playgroud)
返回:
v0.10.25
Run Code Online (Sandbox Code Playgroud)
谁能解释一下出了什么问题?我该如何补救这种情况?
非常感谢。
小智 20
使用 nvm(节点版本管理器)是更新节点默认版本的最佳选择。
安装或更新 nvm:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
Run Code Online (Sandbox Code Playgroud)
或者
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
Run Code Online (Sandbox Code Playgroud)安装成功后,关闭终端并打开一个新终端。列出可用的 nodejs 版本:
nvm ls-remote
Run Code Online (Sandbox Code Playgroud)
这将列出 nodejs 的可用版本。
选择要安装的版本:
nvm install xxxxxx
Run Code Online (Sandbox Code Playgroud)检查版本:
node -v
Run Code Online (Sandbox Code Playgroud)希望这有助于作为分步指南。
最后我厌倦了无处可去。
作为修复,我决定使用 nvm(节点版本管理器)。
安装、设置和使用都非常简单。用不到 3 分钟的时间恢复并运行 nodejs 版本 5。
https://github.com/creationix/nvm
我写这个是为了完整性。