[英]Ubuntu: Node will not update to latest version
I have an issue on my Ubuntu VM.我的 Ubuntu VM 有问题。 I have tried several methods of updating to the latest Nodejs version (both LTS and Current), but running
node --version
still shows v4.8.4.我尝试了几种更新到最新 Nodejs 版本(LTS 和 Current)的方法,但运行
node --version
仍然显示 v4.8.4。
I have tried using both n
and nvm
to update, as well as manually downloading and building.我尝试使用
n
和nvm
进行更新,以及手动下载和构建。 No matter what, v4.8.4 seems to be the only version running.无论如何,v4.8.4 似乎是唯一运行的版本。
If I run which node
I get ~/.nvm/versions/node/v8.2.1/bin/node
.如果我运行
which node
我会得到~/.nvm/versions/node/v8.2.1/bin/node
。 This looks correct, but node --version
is still v4.8.4.这看起来是正确的,但
node --version
仍然是 v4.8.4。
How can I fix this?我该如何解决这个问题?
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
Only this one is working the rest of the methods are not useful for the node只有这个在工作,其余的方法对节点没有用
In Ubuntu 16.04 its works:在 Ubuntu 16.04 中,它的工作原理是:
Edit or create the file :nodesource.list编辑或创建文件 :nodesource.list
sudo gedit /etc/apt/sources.list.d/nodesource.list
Insert this text:插入这段文字:
deb https://deb.nodesource.com/node_10.x bionic main
deb https://deb.nodesource.com/node_10.x仿生主
deb-src https://deb.nodesource.com/node_10.x bionic main
deb-src https://deb.nodesource.com/node_10.x仿生主
Run these commands:运行这些命令:
curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
sudo sh -c "echo deb https://deb.nodesource.com/node_10.x cosmic main /etc/apt/sources.list.d/nodesource.list"
sudo apt-get update
sudo apt-get install nodejs
Thank you everyone for trying to help.谢谢大家的帮助。 The link @ScottStensland provided above ( https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version ) solved the issue for me.
上面提供的链接@ScottStensland( https://askubuntu.com/questions/426750/how-can-i-update-my-nodejs-to-the-latest-version )为我解决了这个问题。 I needed a link!
我需要一个链接!
sudo ln -sf ~/.nvm/versions/node/v8.5.0/bin/node /usr/bin/nodejs
It's unclear what you have already tried - "I have tried several methods" isn't enough information for me to help you.不清楚您已经尝试过什么 - “我已经尝试了几种方法”对我来说不足以帮助您。 But I will give it a try ;-)
但我会试一试;-)
You should know which Ubuntu version your virtual mashine offers.您应该知道您的虚拟主机提供哪个 Ubuntu 版本。 Just type in your terminal:
lsb_release -a
只需在您的终端中输入:
lsb_release -a
Now you are free to follow the instructions from:现在您可以按照以下说明操作:
How can I update my nodeJS to the latest version? 如何将我的 nodeJS 更新到最新版本?
or: Installing Node.js via package manager或:通过包管理器安装 Node.js
Have you tried cleaning your cache and re-installing using a clean version?您是否尝试过清理缓存并使用干净版本重新安装?
Using Command Line/Terminal:使用命令行/终端:
sudo npm cache clean -f
sudo npm install -g n
sudo n 0.8.11
sudo n stable
node -v
node -v will check for the current version of node.js installed on your system. node -v 将检查您系统上安装的 node.js 的当前版本。
In addition you can try installing globally using:此外,您可以尝试使用以下方法进行全局安装:
npm install npm@latest -g
Or manage your NPM versioning using at https://github.com/creationix/nvm :或者使用https://github.com/creationix/nvm管理您的 NPM 版本控制:
nvm use system
nvm run system --version
nvm install node
Hope this helps!希望这有帮助!
You can:你可以:
sudo apt-get remove nodejs
Then:然后:
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm
Check if it was updated检查它是否已更新
nodejs -v
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.