简体   繁体   English

无法安装最新版本的Node.js

[英]Unable to install of latest version of nodejs

I was having nodejs version 4.2.6 in my ubuntu 16.04 pc. 我在Ubuntu 16.04 PC中使用的是Nodejs 4.2.6版本。 I tried to install n using command sudo npm install -gn , and the following errors came out. 我尝试使用命令sudo npm install -gn安装n,出现以下错误。

Node.js 4 is supported but the specific version you're running has

a bug known to break npm. 一个已知会破坏npm的错误。 Please update to at least 4.7.0 to use this version of npm. 请至少更新到4.7.0才能使用此版本的npm。 You can find the latest release of Node.js at https://nodejs.org/ 您可以在https://nodejs.org/上找到最新版本的Node.js。

I uninstalled the current nodejs and then reinstalled it .But everytime the version 4.2.6 is installed.I am not getting why the latest version is not installed.I followed this link to reinstall my nodejs enter link description here 我卸载了当前的nodejs,然后重新安装了它。但是每次安装4.2.6版本时,我都无法理解为什么未安装最新版本。我按照此链接重新安装了nodejs, 在此输入链接描述

Do i need any others updated to have latest nodejs ?Please guide me 我需要其他任何更新以拥有最新的nodejs吗?请指导我

Here are the steps to follow: 以下是要遵循的步骤:

  1. First clear cache. 首先清除缓存。
  2. Then upgrade npm 然后升级npm
  3. Then install stable version if Node 然后如果节点安装稳定版本
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

If that still didt work 如果那还是没用

  1. Remove NodeJs and Npm 删除NodeJ和Npm
  2. Install Node 安装节点
sudo apt remove nodejs npm
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

You can install latest version of nodejs by adding local apt repo as mention in official doc , 您可以通过添加本地apt repo来安装最新版本的nodejs,如官方文档中所述

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

and then use n or nvm module to manage version. 然后使用nnvm模块来管理版本。

Update: You should uninstall older version before installing newer version 更新:您应该先卸载旧版本,然后再安装新版本

sudo apt-get purge nodejs
sudo apt-get autoremove

you can use nvm and install severall version of node and switch on node version 您可以使用nvm并安装几个版本的节点并打开节点版本

this link help you 此链接可以帮助您

enter link description here 在此处输入链接说明

使用NVM管理所有节点版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM