日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Ubuntu >内容正文

Ubuntu

Ubuntu安装源安装nodejs

發(fā)布時間:2025/6/15 Ubuntu 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Ubuntu安装源安装nodejs 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

2019獨角獸企業(yè)重金招聘Python工程師標準>>>

本文演示Ubuntu安裝nodejs,當前(2017年11月13日)最新穩(wěn)定版本為9.x。

#安裝nodejs9.x curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -

下面是安裝具體步驟演示代碼。(以實際代碼運行結(jié)果為準,僅供參考)

root@minmin-VirtualBox:~# curl -sL https://deb.nodesource.com/setup | sudo bash - #root賬號去掉sudo root@minmin-VirtualBox:~# curl -sL https://deb.nodesource.com/setup | bash - ================================================================================ ================================================================================SCRIPT DEPRECATION WARNINGThis script, located at https://deb.nodesource.com/setup, used toinstall Node.js v0.10, is being deprecated and will eventually be madeinactive.You should use the script that corresponds to the version of Node.js youwish to install. e.g.* https://deb.nodesource.com/setup_4.x — Node.js v4 LTS "Argon" (recommended)* https://deb.nodesource.com/setup_6.x — Node.js v6 CurrentPlease see https://github.com/nodejs/LTS/ for details about which versionmay be appropriate for you.The NodeSource Node.js Linux distributions GitHub repository containsinformation about which versions of Node.js and which Linux distributionsare supported and how to use the install scripts.https://github.com/nodesource/distributions================================================================================ ================================================================================Continuing in 10 seconds (press Ctrl-C to abort) ...## Installing the NodeSource Node.js v0.10 repo...## Populating apt-get cache...+ apt-get update 命中:1 http://cn.archive.ubuntu.com/ubuntu xenial InRelease 獲取:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB] 獲取:3 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB] 獲取:4 http://cn.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB] 獲取:5 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [653 kB] 命中:6 http://ppa.launchpad.net/elementary-os/stable/ubuntu xenial InRelease 獲取:7 http://packages.elementary.io/appcenter xenial InRelease [5,894 B] 獲取:8 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [618 kB] 命中:9 http://ppa.launchpad.net/elementary-os/os-patches/ubuntu xenial InRelease 獲取:10 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease [46.4 kB] 獲取:11 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main amd64 Packages [72.5 kB] 獲取:12 http://security.ubuntu.com/ubuntu xenial-security/main amd64 DEP-11 Metadata [60.3 kB] 獲取:13 http://packages.elementary.io/appcenter xenial/main amd64 Packages [39.1 kB] 獲取:14 http://apt.postgresql.org/pub/repos/apt xenial-pgdg/main i386 Packages [70.6 kB] 獲取:15 http://security.ubuntu.com/ubuntu xenial-security/main DEP-11 64x64 Icons [67.1 kB] 獲取:16 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [274 kB] 獲取:17 http://packages.elementary.io/appcenter xenial/main amd64 DEP-11 Metadata [31.4 kB] 獲取:18 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main amd64 DEP-11 Metadata [307 kB] 獲取:19 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 DEP-11 Metadata [51.4 kB] 獲取:20 http://packages.elementary.io/appcenter xenial/main DEP-11 64x64 Icons [171 kB] 獲取:21 http://security.ubuntu.com/ubuntu xenial-security/universe DEP-11 64x64 Icons [85.1 kB] 獲取:22 http://cn.archive.ubuntu.com/ubuntu xenial-updates/main DEP-11 64x64 Icons [220 kB] 獲取:23 http://cn.archive.ubuntu.com/ubuntu xenial-updates/restricted amd64 Packages [8,064 B] 獲取:24 http://cn.archive.ubuntu.com/ubuntu xenial-updates/restricted i386 Packages [8,084 B] 獲取:25 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [544 kB] 獲取:26 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe i386 Packages [518 kB] 獲取:27 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [221 kB] 獲取:28 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 DEP-11 Metadata [174 kB] 獲取:29 http://cn.archive.ubuntu.com/ubuntu xenial-updates/universe DEP-11 64x64 Icons [245 kB] 獲取:30 http://cn.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 Packages [16.2 kB] 獲取:31 http://cn.archive.ubuntu.com/ubuntu xenial-updates/multiverse i386 Packages [15.3 kB] 獲取:32 http://cn.archive.ubuntu.com/ubuntu xenial-updates/multiverse amd64 DEP-11 Metadata [5,888 B] 獲取:33 http://cn.archive.ubuntu.com/ubuntu xenial-backports/main amd64 DEP-11 Metadata [3,324 B] 獲取:34 http://cn.archive.ubuntu.com/ubuntu xenial-backports/universe amd64 DEP-11 Metadata [4,588 B] 已下載 4,841 kB,耗時 19秒 (246 kB/s) 正在讀取軟件包列表... 完成## You seem to be using elementaryOS version loki. ## This maps to Ubuntu "xenial"... Adjusting for you...## Confirming "xenial" is supported...+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_0.10/dists/xenial/Release'## Adding the NodeSource signing key to your keyring...+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - OK## Creating apt sources list file for the NodeSource Node.js v0.10 repo...+ echo 'deb https://deb.nodesource.com/node_0.10 xenial main' > /etc/apt/sources.list.d/nodesource.list + echo 'deb-src https://deb.nodesource.com/node_0.10 xenial main' >> /etc/apt/sources.list.d/nodesource.list## Running `apt-get update` for you...+ apt-get update 命中:1 http://cn.archive.ubuntu.com/ubuntu xenial InRelease 命中:2 http://cn.archive.ubuntu.com/ubuntu xenial-updates InRelease 命中:3 http://cn.archive.ubuntu.com/ubuntu xenial-backports InRelease 命中:4 http://security.ubuntu.com/ubuntu xenial-security InRelease 命中:5 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease 命中:6 http://packages.elementary.io/appcenter xenial InRelease 命中:7 http://ppa.launchpad.net/elementary-os/stable/ubuntu xenial InRelease 獲取:8 https://deb.nodesource.com/node_0.10 xenial InRelease [3,899 B] 獲取:9 https://deb.nodesource.com/node_0.10 xenial/main Sources [682 B] 獲取:10 https://deb.nodesource.com/node_0.10 xenial/main amd64 Packages [932 B] 獲取:11 https://deb.nodesource.com/node_0.10 xenial/main i386 Packages [932 B] 命中:12 http://ppa.launchpad.net/elementary-os/os-patches/ubuntu xenial InRelease 已下載 6,445 B,耗時 4秒 (1,414 B/s) 正在讀取軟件包列表... 完成================================================================================ ================================================================================NODE.JS v0.10 DEPRECATION WARNINGNode.js v0.10 will cease to be actively supported in October 2016.This means you will not continue to receive security or critical stabilityupdates for this version of Node.js beyond that time.You should begin migration to a newer version of Node.js as soon aspossible. Use the installation script that corresponds to the version ofNode.js you wish to install. e.g.* https://deb.nodesource.com/setup_4.x — Node.js v4 LTS "Argon" (recommended)* https://deb.nodesource.com/setup_6.x — Node.js v6 CurrentPlease see https://github.com/nodejs/LTS/ for details about which versionmay be appropriate for you.The NodeSource Node.js Linux distributions GitHub repository containsinformation about which versions of Node.js and which Linux distributionsare supported and how to use the install scripts.https://github.com/nodesource/distributions================================================================================ ================================================================================Continuing in 5 seconds ...## Run `apt-get install nodejs` (as root) to install Node.js v0.10 and npm

切換到root 賬號或使用root賬戶權限。

root@minmin-VirtualBox:~# sudo -i #輸入root用戶密碼 root@minmin-VirtualBox:~# apt update root@minmin-VirtualBox:~# apt install nodejs nodejs-dev nodejs-dbg debhelper

完成安裝后,就可以使用npm,檢查版本信息。

root@minmin-VirtualBox:~# nodejs -v v9.1.0

使用淘寶安裝源替換系統(tǒng)默認npm,等待安裝進度完成。

root@minmin-VirtualBox:~# npm install -g cnpm --registry=https://registry.npm.taobao.org [ ......] - extract:balanced-match: sill pacote balanced-match@http://registry.npm.taobao.org/balanced-match/download/balanced-matc /usr/bin/cnpm -> /usr/lib/node_modules/cnpm/bin/cnpm + cnpm@5.1.1 added 692 packages in 1202.934s

演示安裝http-server。

root@minmin-VirtualBox:~# cnpm install -g http-server Downloading http-server to /usr/lib/node_modules/http-server_tmp [npminstall:get] retry GET http://registry.npm.taobao.org/http-server/download/http-server-0.10.0.tgz after 100ms, retry left 4, error: ConnectionTimeoutError: Connect timeout for 60000ms, GET https://cdn.npm.taobao.org/http-server/-/http-server-0.10.0.tgz -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":1,"createSocketErrorCount":0,"closeSocketCount":1,"errorSocketCount":0,"timeoutSocketCount":0,"requestCount":0,"freeSockets":{},"sockets":{},"requests":{}}) headers: {} Copying /usr/lib/node_modules/http-server_tmp/_http-server@0.10.0@http-server to /usr/lib/node_modules/http-server Installing http-server's dependencies to /usr/lib/node_modules/http-server/node_modules [1/8] opener@~1.4.0 installed at node_modules/_opener@1.4.3@opener [2/8] colors@1.0.3 installed at node_modules/_colors@1.0.3@colors [3/8] optimist@0.6.x installed at node_modules/_optimist@0.6.1@optimist [4/8] ecstatic@^2.0.0 installed at node_modules/_ecstatic@2.2.1@ecstatic [npminstall:get] retry GET http://registry.npm.taobao.org/corser/download/corser-2.0.1.tgz after 100ms, retry left 4, error: ConnectionTimeoutError: Connect timeout for 60000ms, GET https://cdn.npm.taobao.org/corser/-/corser-2.0.1.tgz -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":9,"createSocketErrorCount":0,"closeSocketCount":6,"errorSocketCount":0,"timeoutSocketCount":4,"requestCount":11,"freeSockets":{},"sockets":{"cdn.npm.taobao.org:443:::::::true::":3},"requests":{}}) headers: {} [npminstall:get] retry GET http://registry.npm.taobao.org/http-proxy/download/http-proxy-1.16.2.tgz after 100ms, retry left 4, error: ConnectionTimeoutError: Connect timeout for 60000ms, GET https://cdn.npm.taobao.org/http-proxy/-/http-proxy-1.16.2.tgz -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":9,"createSocketErrorCount":0,"closeSocketCount":7,"errorSocketCount":0,"timeoutSocketCount":4,"requestCount":11,"freeSockets":{},"sockets":{"cdn.npm.taobao.org:443:::::::true::":2},"requests":{}}) headers: {} [npminstall:get] retry GET http://registry.npm.taobao.org/union/download/union-0.4.6.tgz after 100ms, retry left 4, error: ConnectionTimeoutError: Connect timeout for 60000ms, GET https://cdn.npm.taobao.org/union/-/union-0.4.6.tgz -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":9,"createSocketErrorCount":0,"closeSocketCount":8,"errorSocketCount":0,"timeoutSocketCount":4,"requestCount":11,"freeSockets":{},"sockets":{"cdn.npm.taobao.org:443:::::::true::":1},"requests":{}}) headers: {} [npminstall:get] retry GET http://registry.npm.taobao.org/portfinder/download/portfinder-1.0.13.tgz after 100ms, retry left 4, error: ConnectionTimeoutError: Connect timeout for 60000ms, GET https://cdn.npm.taobao.org/portfinder/-/portfinder-1.0.13.tgz -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":9,"createSocketErrorCount":0,"closeSocketCount":9,"errorSocketCount":0,"timeoutSocketCount":4,"requestCount":11,"freeSockets":{},"sockets":{},"requests":{}}) headers: {} [5/8] union@~0.4.3 installed at node_modules/_union@0.4.6@union [npminstall:get] retry GET http://registry.npm.taobao.org/corser/download/corser-2.0.1.tgz after 200ms, retry left 3, error: ConnectionTimeoutError: Connect timeout for 60000ms, GET https://cdn.npm.taobao.org/corser/-/corser-2.0.1.tgz -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":14,"createSocketErrorCount":0,"closeSocketCount":12,"errorSocketCount":0,"timeoutSocketCount":6,"requestCount":17,"freeSockets":{},"sockets":{"cdn.npm.taobao.org:443:::::::true::":2},"requests":{}}) headers: {} [npminstall:get] retry GET http://registry.npm.taobao.org/http-proxy/download/http-proxy-1.16.2.tgz after 200ms, retry left 3, error: ConnectionTimeoutError: Connect timeout for 60000ms, GET https://cdn.npm.taobao.org/http-proxy/-/http-proxy-1.16.2.tgz -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":14,"createSocketErrorCount":0,"closeSocketCount":13,"errorSocketCount":0,"timeoutSocketCount":6,"requestCount":17,"freeSockets":{},"sockets":{"cdn.npm.taobao.org:443:::::::true::":1},"requests":{}}) headers: {} [npminstall:get] retry GET http://registry.npm.taobao.org/mkdirp/download/mkdirp-0.5.1.tgz after 100ms, retry left 4, error: ConnectionTimeoutError: Connect timeout for 60000ms, GET https://cdn.npm.taobao.org/mkdirp/-/mkdirp-0.5.1.tgz -2 (connected: false, keepalive socket: false, agent status: {"createSocketCount":16,"createSocketErrorCount":0,"closeSocketCount":14,"errorSocketCount":0,"timeoutSocketCount":6,"requestCount":17,"freeSockets":{},"sockets":{"cdn.npm.taobao.org:443:::::::true::":2},"requests":{}}) headers: {} [6/8] corser@~2.0.0 installed at node_modules/_corser@2.0.1@corser [7/8] portfinder@^1.0.13 installed at node_modules/_portfinder@1.0.13@portfinder [8/8] http-proxy@^1.8.1 installed at node_modules/_http-proxy@1.16.2@http-proxy All packages installed (22 packages installed from npm registry, used 2m, speed 8.77kB/s, json 20(45.15kB), tarball 1020.36kB) [http-server@0.10.0] link /usr/bin/http-server@ -> /usr/lib/node_modules/http-server/bin/http-server [http-server@0.10.0] link /usr/bin/hs@ -> /usr/lib/node_modules/http-server/bin/http-server root@minmin-VirtualBox:~# root@minmin-VirtualBox:~# http-server & [3] 3522 root@minmin-VirtualBox:~# Starting up http-server, serving ./ Available on:http://127.0.0.1:8080http://10.1.1.1:8080 Hit CTRL-C to stop the server root@minmin-VirtualBox:~#

參考鏈接:

https://mirror.tuna.tsinghua.edu.cn/help/nodesource/

http://www.mamicode.com/info-detail-1802382.html

轉(zhuǎn)載于:https://my.oschina.net/u/1011130/blog/1572681

總結(jié)

以上是生活随笔為你收集整理的Ubuntu安装源安装nodejs的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。