ubuntu安装nodejs

SharkChilli      2022-02-14     343

关键词:

更新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 ‘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 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 http://ppa.launchpad.net/chris-lea/node.js/ubuntu trusty main
deb-src http://ppa.launchpad.net/chris-lea/node.js/ubuntu 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和里面在部分网络下会一直下载失败,可以改回官方源下载

源列表

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

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

 



ubuntu下面安装nodejs

对于刚接触ubuntu的同学来说,一切都是新的,一切都是那么熟悉而又不熟悉的.不管是作为一个前端工程师还是一个后端工程师,我相信大家知道nodejs,但是如果希望自己能够在ubuntu上面使用nodejs,是需要给点功夫去做的.当然对于一个ub... 查看详情

Nodejs - 如何在 ubuntu 中卸载旧版本的 nodejs 并安装新版本的 nodejs

】Nodejs-如何在ubuntu中卸载旧版本的nodejs并安装新版本的nodejs【英文标题】:Nodejs-howtouninstallolderversionofnodejsandinstallnewversionofnodejsinubuntu【发布时间】:2019-11-0804:17:45【问题描述】:我的react项目需要更新nodejs。那么我如何在Ubuntu1... 查看详情

sh[安装nodejs]在ubuntulinux17.04#ubuntu#install上安装nodejs(代码片段)

查看详情

ubuntu下使用nvm安装nodejs

sudoapt-getinstallcurlcurl-o-https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh|bash(写这篇文章的时候nvm的版本是0.33.6)重启终端nvminstallnode这样就可以安装好nodejs了 查看详情

ubuntu通过tnvm安装nodejs

第一步,先安装tvmtnvm(TaobaoNodeVersionManager)淘宝Node版本管理器安装:直接输入wget-O-https://raw.githubusercontent.com/aliyun-node/tnvm/master/install.sh|bash等待完成后,输入exportMETHOD=script添加环境变量,在输入source.bashrc使环境变量生效来安装完... 查看详情

在ubuntu16.04下安装nodejs

源安装:1.curl-sLhttps://deb.nodesource.com/setup_5.x|sudo-Ebash- 2.sudoapt-getinstall-ynodejs使用命令安装看到此图,安装成功!使用node-v查看弄的js版本号   查看详情

优雅地乱玩linux-3-ubuntu下nodejs的安装

文章最初发表于szhshp的第三边境研究所转载请注明Ubuntu16.04安装NodeJS天哪Linux安装NodeJS居然也这么麻烦NodeJS安装curl-sLhttps://deb.nodesource.com/setup_6.x|sudo-Ebash-sudoapt-getinstall-ynodejs可能会出现找不到 curl的错误, apt-get一下curl就可... 查看详情

ubuntu下安装nodejs以及pm2

 ubuntu12.04服务器可以使用apt-get方式安装NodeJS,但是,安装完后的版本为v0.6.12的版本,如果我们想要使用新一点的版本需要做如下配置: 1234apt-getinstallpython-software-propertiesapt-add-repositoryppa:chris-lea/node.jsapt-getupdateapt-getinsta 查看详情

ubuntu怎么安装nodejs

...sp;检查是否安装成功。上面的安装步骤参考了这篇文章:Ubuntu20.04通过命令行安装nodeJs 查看详情

ubuntu安装nodejs(代码片段)

~#wgethttps://nodejs.org/dist/v4.1.1/node-v4.1.1-linux-x64.tar.gz~#tar-vxfnode-v4.1.1-linux-x64.tar.gz~#mvnode-v4.1.1-linux-x64nodejs~#vi/etc/profile.d/node.shexportNODE_HOME=~/nodejsexportPATH 查看详情

ubuntu20.04通过apt方式(命令行)安装nodejs

参考技术AUbuntu的默认安装源有点坑,直接使用sudoaptinstallnodejs安装的nodeJs版本比较老旧,到写这篇博客为止,使用这条命令安装的仅仅只有nodejs,并不包含npm。需要通过以下步骤,才能安装到最新版本或指定版本的nodeJs,并且是... 查看详情

腾讯云(ubuntu)下安装nodejs+实现nginx反向代理

本文将介绍如何给腾讯云上的UbuntuServer12.04LTS64位主机安装node及nginx,并简单配置反向代理。笔者在整个安装过程中遇到不少麻烦(不赘述),如果你希望少踩坑,可以按本文的步骤进行安装部署。一.新版nodejs安装这里强烈推荐... 查看详情

使用分发 nodejs 包将 NPM 安装到主目录(Ubuntu)

】使用分发nodejs包将NPM安装到主目录(Ubuntu)【英文标题】:InstallNPMintohomedirectorywithdistributionnodejspackage(Ubuntu)【发布时间】:2012-04-2207:16:42【问题描述】:我想使用分发的Node.js包(或chris-leappa以获得最新版本),但将NPM安装到... 查看详情

在 ubuntu os 的 nginx Web 服务器上安装 nodejs 和 mongodb

】在ubuntuos的nginxWeb服务器上安装nodejs和mongodb【英文标题】:installingnodejsandmongodbonnginxwebserverinubuntuos【发布时间】:2016-11-1901:04:14【问题描述】:我正在尝试在ubuntu操作系统的nginx网络服务器上安装nodejs和mongodb,但我没有得到它... 查看详情

是否可以在虚拟机上的 ubuntu 服务器 20.04 上安装 nodejs?

】是否可以在虚拟机上的ubuntu服务器20.04上安装nodejs?【英文标题】:Isitpossibletoinstallnodejsonubuntuserver20.04onavirtualmachine?【发布时间】:2021-09-2416:36:39【问题描述】:我在虚拟机上的UbuntuServer20.04上安装NodeJs和NPM时遇到问题。“解... 查看详情

ubuntu16.04下安装配置nodejs及npm(代码片段)

官网下载ubuntu对应的二进制文件(LinuxBinaries(x64)这一行)https://nodejs.org/en/download/解压并安装```$tarzxvfnode-v0.10.24.tar.gz#解压后进入对应目录$sudochmod-R755node$sudo./configure$sudomake$sudomakeinstall```大功告成```$node-v$npm- 查看详情

ubuntu安装nodejs后无法使用npm命令

错误提示:Cannotfindmodule‘../lib/utils/unsupported.js‘解决方法:卸载重装node解决过程:执行sudoapt-getremovenodejs,node-v仍能输出node版本号,卸载失败执行sudoapt-getremove--purgenpmsudoapt-getremove--purgenodejssudoapt-getremove--purgen 查看详情

如何在ubuntu14.04服务器上安装nodejs

Ubuntu14.04为了保证跨平台服务体验的一致性,在它的仓库中默认包含了一个版本为0.10.25的Node.JS,这个可能不是最新版本,但是却一定是标准发行版本。要想获取这个版本的Node.JS,我们只要通过apt包管理工具来安装就可以。在安... 查看详情