分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 软件开发

【转载】Ubuntu16.04安装最新版nodejs

发布时间:2023-09-06 01:44责任编辑:沈小雨关键词:jsnodejs

安装最新版nodejs

更新ubuntu软件源
sudo apt-get updatesudo apt-get install -y python-software-properties software-properties-commonsudo add-apt-repository ppa:chris-lea/node.jssudo apt-get update

安装nodejs

sudo apt-get install nodejssudo apt install nodejs-legacysudo apt install npm

更新npm的包镜像源,方便快速下载

sudo npm config set registry https://registry.npm.taobao.orgsudo npm config list
全局安装n管理器(用于管理nodejs版本)
sudo npm install n -g

安装最新的nodejs(stable版本)

sudo n stablesudo node -v

QA

Q: apt-get update找不到文件

// error codeW: The repository ‘http://ppa.launchpad.net/chris-lea/node.js/ubuntu 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 http://ppa.launchpad.net/chris-lea/node.js/ubuntu/dists/xenial/main/binary-amd64/Packages ?404 ?Not FoundE: 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.listdeb http://ppa.launchpad.net/chris-lea/node.js/ubuntu trusty maindeb-src http://ppa.launchpad.net/chris-lea/node.js/ubuntu trusty main

Q: node -v异常

node -v-bash: /usr/local/bin/node: Permission deniedsudo node -vSegmentation 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和里面在部分网络下会一直下载失败,可以改回官方源下载

源列表

http://wiki.ubuntu.org.cn/模板:16.04source

Ubuntu官方
deb http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiversedeb http://cn.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiversedeb http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiversedeb http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiversedeb http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ xenial main restricted universe multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-security main restricted universe multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-updates main restricted universe multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiversedeb-src http://cn.archive.ubuntu.com/ubuntu/ xenial-proposed main restricted universe multiverse

小礼物走一走,来简书关注我



作者:十戒s
链接:https://www.jianshu.com/p/2b24cd430a7d
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

【转载】Ubuntu16.04安装最新版nodejs

原文地址:https://www.cnblogs.com/lidonghao/p/8495895.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved