Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3279745
  • 博文数量: 515
  • 博客积分: 5116
  • 博客等级: 大校
  • 技术积分: 4137
  • 用 户 组: 普通用户
  • 注册时间: 2006-09-30 11:24
个人简介

黑马王子就是我! 技术认证:系统分析师,网络规划设计师,网络工程师,信息系统监理师,系统集成项目管理师,初级程序员,MCSE,MCDBA,CCNA 目前主攻虚拟化技术,VPN,系统架构,集群和高可用性等。

文章分类

全部博文(515)

文章存档

2023年(11)

2022年(17)

2021年(19)

2020年(28)

2019年(42)

2018年(53)

2017年(41)

2016年(33)

2015年(43)

2014年(25)

2013年(13)

2011年(6)

2010年(28)

2009年(47)

2008年(55)

2007年(26)

2006年(28)

分类: JavaScript

2018-07-16 15:01:53

      最近公司服务器因为某些原因,导致服务器环境需要全部重新部署,安装nodejs又忘了,记录下,方便下次使用。

安装最新版nodejs

更新ubuntu软件源
sudo apt-get update
sudo apt-get install -y python-software-properties software-properties-common
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update 
安装nodejs
sudo apt-get install nodejs
sudo apt install nodejs-legacy
sudo apt install npm 
更新npm的包镜像源,方便快速下载
sudo npm config set registry https://registry.npm.taobao.org sudo npm config list 
全局安装n管理器(用于管理nodejs版本)
sudo npm install n -g 
安装最新的nodejs(stable版本)
sudo n stable
sudo node -v 

QA

Q: apt-get update找不到文件

// error code W: The repository ' xenial Release' does not have a Release file.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: Failed to fetch /dists/xenial/main/binary-amd64/Packages  404  Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.

// A: 修改node相关文件:/etc/apt/sources.list.d/chris-lea-ubuntu-node_js-xenial.list
deb  trusty main
deb-src  trusty main 

Q: node -v异常

node -v
-bash: /usr/local/bin/node: Permission denied

sudo node -v
Segmentation fault (core dumped)

// A: 重新安装nodejs
手动移除 /usr/local/lib/node_modules整个目录
手动移除 /usr/local/bin/node
手动移除 /usr/local/bin/n
手动移除 /usr/local/bin/npm 

ubuntu软件源

修改/etc/apt/sources.list为以下软件源(改前请备份)
163和里面在部分网络下会一直下载失败,可以改回官方源下载

源列表



作者:十戒s
链接:
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
阅读(1371) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~