自分用のメモです。参考URLほぼ同じですがコピペがやりにくいので自分用にメモを残す
あと実行ログがないとあとで動かなくなった時に困るので追記した
コマンドを実行し、リポジトリを追加します。
$ curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash $ curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add $ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
クリックするとログが展開されます
sudo: unable to resolve host hostnamexxxx ## Installing the NodeSource Node.js 10.x repo... ## Populating apt-get cache... + apt-get update Hit:1 http://jp.archive.ubuntu.com/ubuntu xenial InRelease Hit:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates InRelease Hit:3 http://jp.archive.ubuntu.com/ubuntu xenial-backports InRelease Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Fetched 107 kB in 1s (94.8 kB/s) Reading package lists... Done ## Confirming "xenial" is supported... + curl -sLf -o /dev/null 'https://deb.nodesource.com/node_10.x/dists/xenial/Rele ase' ## 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 10.x repo... + echo 'deb https://deb.nodesource.com/node_10.x xenial main' > /etc/apt/sources .list.d/nodesource.list + echo 'deb-src https://deb.nodesource.com/node_10.x xenial main' >> /etc/apt/so urces.list.d/nodesource.list ## Running `apt-get update` for you... + apt-get update Hit:1 http://jp.archive.ubuntu.com/ubuntu xenial InRelease Hit:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates InRelease Hit:3 http://jp.archive.ubuntu.com/ubuntu xenial-backports InRelease Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease Get:5 https://deb.nodesource.com/node_10.x xenial InRelease [4,611 B] Get:6 https://deb.nodesource.com/node_10.x xenial/main amd64 Packages [763 B] Fetched 5,374 B in 0s (5,901 B/s) Reading package lists... Done ## Run `sudo apt-get install -y nodejs` to install Node.js 10.x and npm ## You may also need development tools to build native addons: sudo apt-get install gcc g++ make ## To install the Yarn package manager, run: curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/s ources.list.d/yarn.list sudo apt-get update && sudo apt-get install yarn $ curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add sudo: unable to resolve host hostnamexxxx OK $ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo: unable to resolve host hostnamexxxx
コマンドを実行し、リポジトリ一覧を更新します。
$ sudo apt update
クリックするとログが展開されます
$ /node# sudo apt update sudo: unable to resolve host v133-18-201-67 Hit:1 http://jp.archive.ubuntu.com/ubuntu xenial InRelease Hit:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates InRelease Hit:3 http://jp.archive.ubuntu.com/ubuntu xenial-backports InRelease Get:4 https://dl.yarnpkg.com/debian stable InRelease [13.3 kB] Get:5 https://dl.yarnpkg.com/debian stable/main amd64 Packages [7,416 B] Hit:6 https://deb.nodesource.com/node_10.x xenial InRelease Get:7 https://dl.yarnpkg.com/debian stable/main i386 Packages [7,416 B] Hit:8 http://security.ubuntu.com/ubuntu xenial-security InRelease Get:9 https://dl.yarnpkg.com/debian stable/main all Packages [7,416 B] Fetched 35.6 kB in 0s (61.3 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done 139 packages can be upgraded. Run 'apt list --upgradable' to see them.
コマンドを実行し、Node.js 10.xをインストールします。
$ sudo apt install nodejs yarn build-essential
クリックするとログが展開されます
$ sudo apt install nodejs yarn build-essential sudo: unable to resolve host v133-18-201-67 Reading package lists... Done Building dependency tree Reading state information... Done build-essential is already the newest version (12.1ubuntu2). build-essential set to manually installed. The following packages were automatically installed and are no longer required: gyp javascript-common libjs-inherits libjs-jquery libjs-node-uuid libjs-underscore libssl-dev libssl-doc libuv1 libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-block-stream node-combined-stream node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fstream node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs node-gyp node-inherits node-ini node-json-stringify-safe node-lockfile node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once node-osenv node-qs node-read node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-sigmund node-slide node-tar node-tunnel-agent node-underscore node-which zlib1g-dev Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: nodejs-dev npm The following NEW packages will be installed: yarn The following packages will be upgraded: nodejs 1 upgraded, 1 newly installed, 2 to remove and 138 not upgraded. Need to get 14.4 MB of archives. After this operation, 43.9 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 https://dl.yarnpkg.com/debian stable/main amd64 yarn all 1.9.2-1 [684 kB] Get:2 https://deb.nodesource.com/node_10.x xenial/main amd64 nodejs amd64 10.7.0-1nodesource1 [13.8 MB] Fetched 14.4 MB in 2s (6,723 kB/s) (Reading database ... 102854 files and directories currently installed.) Removing npm (3.5.2-0ubuntu4) ... dpkg: nodejs-dev: dependency problems, but removing anyway as you requested: node-gyp depends on nodejs-dev. Removing nodejs-dev (4.2.6~dfsg-1ubuntu4.1) ... Processing triggers for man-db (2.7.5-1) ... (Reading database ... 99796 files and directories currently installed.) Preparing to unpack .../nodejs_10.7.0-1nodesource1_amd64.deb ... Unpacking nodejs (10.7.0-1nodesource1) over (4.2.6~dfsg-1ubuntu4.1) ... Selecting previously unselected package yarn. Preparing to unpack .../archives/yarn_1.9.2-1_all.deb ... Unpacking yarn (1.9.2-1) ... Processing triggers for man-db (2.7.5-1) ... Setting up nodejs (10.7.0-1nodesource1) ... Setting up yarn (1.9.2-1) ...
バージョンの確認
$ nodejs -v v 10.7.0 # yarn -v 1.9.2 # npm -v 6.1.0
参考URL