Install latest version of NodeJS on Ubuntu 22.04 LTS

0
628
Install latest version of NodeJS on Ubuntu 22.04 LTS
Install latest version of NodeJS on Ubuntu 22.04 LTS

We will go through how to install the latest version of NodeJS on Ubuntu. Node.js is a back-end JavaScript runtime environment that is open-source, cross-platform, runs on the V8 engine, and executes JavaScript code outside of a web browser. It was created to help create scalable network applications.

Table of Contents

- Advertisement -

How to install Node.js on Ubuntu 22.04

Update your system using the command below.

sudo apt update

Next, install NodeJS using the following command.

sudo apt install nodejs -y

Sample output

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  javascript-common libc-ares2 libjs-highlight.js libnode72
  nodejs-doc
Suggested packages:
  apache2 | lighttpd | httpd npm
The following NEW packages will be installed:
  javascript-common libc-ares2 libjs-highlight.js libnode72
  nodejs nodejs-doc
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 13.7 MB of archives.
After this operation, 53.9 MB of additional disk space will be used.
Get:1 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 javascript-common all 11+nmu1 [5,936 B]
Get:2 http://ke.archive.ubuntu.com/ubuntu jammy/universe amd64 libjs-highlight.js all 9.18.5+dfsg1-1 [367 kB]
Get:3 http://ke.archive.ubuntu.com/ubuntu jammy/main amd64 libc-ares2 amd64 1.18.1-1build1 [44.9 kB]
Get:4 http://ke.archive.ubuntu.com/ubuntu jammy/universe amd64 libnode72 amd64 12.22.9~dfsg-1ubuntu3 [10.8 MB]
Get:5 http://ke.archive.ubuntu.com/ubuntu jammy/universe amd64 nodejs-doc all 12.22.9~dfsg-1ubuntu3 [2,409 kB]
Get:6 http://ke.archive.ubuntu.com/ubuntu jammy/universe amd64 nodejs amd64 12.22.9~dfsg-1ubuntu3 [122 kB]
Fetched 13.7 MB in 4min 57s (46.2 kB/s)                        
Selecting previously unselected package javascript-common.
(Reading database ... 195383 files and directories currently installed.)
Preparing to unpack .../0-javascript-common_11+nmu1_all.deb ...
Unpacking javascript-common (11+nmu1) ...
Selecting previously unselected package libjs-highlight.js.
Preparing to unpack .../1-libjs-highlight.js_9.18.5+dfsg1-1_all.deb ...
Unpacking libjs-highlight.js (9.18.5+dfsg1-1) ...
Selecting previously unselected package libc-ares2:amd64.
Preparing to unpack .../2-libc-ares2_1.18.1-1build1_amd64.deb ...
Unpacking libc-ares2:amd64 (1.18.1-1build1) ...
Selecting previously unselected package libnode72:amd64.
Preparing to unpack .../3-libnode72_12.22.9~dfsg-1ubuntu3_amd64.deb ...
Unpacking libnode72:amd64 (12.22.9~dfsg-1ubuntu3) ...
Selecting previously unselected package nodejs-doc.
Preparing to unpack .../4-nodejs-doc_12.22.9~dfsg-1ubuntu3_all.deb ...
Unpacking nodejs-doc (12.22.9~dfsg-1ubuntu3) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../5-nodejs_12.22.9~dfsg-1ubuntu3_amd64.deb ...
Unpacking nodejs (12.22.9~dfsg-1ubuntu3) ...
Setting up javascript-common (11+nmu1) ...
Setting up libc-ares2:amd64 (1.18.1-1build1) ...
Setting up libnode72:amd64 (12.22.9~dfsg-1ubuntu3) ...
Setting up libjs-highlight.js (9.18.5+dfsg1-1) ...
Setting up nodejs (12.22.9~dfsg-1ubuntu3) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/j
s (js) in auto mode
Setting up nodejs-doc (12.22.9~dfsg-1ubuntu3) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...

How to check NodeJS version

Run the command below to check the NodeJS version.

node -v

Install a specific version of Node js

You can also install a specific version of NodeJS using NodeSource PPA. Start by installing curl using the following command.

sudo apt install curl -y

Sample output

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libcurl4
The following NEW packages will be installed:
  curl
The following packages will be upgraded:
  libcurl4
1 upgraded, 1 newly installed, 0 to remove and 148 not upgraded.
Need to get 484 kB of archives.
After this operation, 457 kB of additional disk space will be used.
Get:1 http://ke.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libcurl4 amd64 7.81.0-1ubuntu1.3 [290 kB]
Get:2 http://ke.archive.ubuntu.com/ubuntu jammy-updates/main amd64 curl amd64 7.81.0-1ubuntu1.3 [194 kB]
Fetched 484 kB in 4s (110 kB/s)
(Reading database ... 195753 files and directories currently ins
talled.)
Preparing to unpack .../libcurl4_7.81.0-1ubuntu1.3_amd64.deb ...
Unpacking libcurl4:amd64 (7.81.0-1ubuntu1.3) over (7.81.0-1ubunt
u1.2) ...
Selecting previously unselected package curl.
Preparing to unpack .../curl_7.81.0-1ubuntu1.3_amd64.deb ...
Unpacking curl (7.81.0-1ubuntu1.3) ...
Setting up libcurl4:amd64 (7.81.0-1ubuntu1.3) ...
Setting up curl (7.81.0-1ubuntu1.3) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...

Next, run the NodeSource script with the specific version of NodeJS you want to install e.g. version 14

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

Then install NodeJS.

sudo apt install nodejs -y

Install the latest version of NPM

Run the command below to install the latest version of npm on your system.

sudo apt install npm -y

Sample output

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libjs-highlight.js
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu
  build-essential dpkg-dev fakeroot g++ g++-11 gcc gcc-11 git
  git-man gyp libalgorithm-diff-perl libalgorithm-diff-xs-perl
  libalgorithm-merge-perl libasan6 libatomic1 libbinutils
  libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
  libctf-nobfd0 libctf0 libdpkg-perl liberror-perl libfakeroot
  libfile-fcntllock-perl libgcc-11-dev libitm1 libjs-events
  libjs-inherits libjs-is-typedarray libjs-psl
  libjs-source-map libjs-sprintf-js libjs-typedarray-to-buffer
  liblsan0 libnode-dev libnsl-dev libquadmath0 libssl-dev
  libssl3 libstdc++-11-dev libtirpc-dev libtsan0 libubsan1
  libuv1-dev linux-libc-dev lto-disabled-list make
  manpages-dev node-abab node-abbrev node-agent-base
  node-ansi-regex node-ansi-styles node-ansistyles node-aproba
  node-archy node-are-we-there-yet node-argparse node-arrify
  node-asap node-asynckit node-balanced-match
  node-brace-expansion node-builtins node-cacache node-chalk
  node-chownr node-clean-yaml-object node-cli-table node-clone
  node-color-convert node-color-name node-colors
  node-columnify node-combined-stream node-commander
  node-console-control-strings node-copy-concurrently
  node-core-util-is node-coveralls node-cssom node-cssstyle
  node-debug node-decompress-response node-defaults
  node-delayed-stream node-delegates node-depd node-diff
  node-encoding node-end-of-stream node-err-code
  node-escape-string-regexp node-esprima node-events
  node-fancy-log node-fetch node-foreground-child
  node-form-data node-fs-write-stream-atomic node-fs.realpath
  node-function-bind node-gauge node-get-stream node-glob
  node-got node-graceful-fs node-growl node-gyp node-has-flag
  node-has-unicode node-hosted-git-info node-https-proxy-agent
  node-iconv-lite node-iferr node-imurmurhash
  node-indent-string node-inflight node-inherits node-ini
  node-ip node-ip-regex node-is-buffer node-is-plain-obj
  node-is-typedarray node-isarray node-isexe node-js-yaml
  node-jsdom node-json-buffer node-json-parse-better-errors
  node-jsonparse node-kind-of node-lcov-parse
  node-lodash-packages node-log-driver node-lowercase-keys
  node-lru-cache node-mime node-mime-types node-mimic-response
  node-minimatch node-minimist node-minipass node-mkdirp
  node-move-concurrently node-ms node-mute-stream
  node-negotiator node-nopt node-normalize-package-data
  node-npm-bundled node-npm-package-arg node-npmlog
  node-object-assign node-once node-opener node-osenv
  node-p-cancelable node-p-map node-path-is-absolute
  node-process-nextick-args node-promise-inflight
  node-promise-retry node-promzard node-psl node-pump
  node-punycode node-quick-lru node-read
  node-read-package-json node-readable-stream node-resolve
  node-retry node-rimraf node-run-queue node-safe-buffer
  node-semver node-set-blocking node-signal-exit node-slash
  node-slice-ansi node-source-map node-source-map-support
  node-spdx-correct node-spdx-exceptions
  node-spdx-expression-parse node-spdx-license-ids
  node-sprintf-js node-ssri node-stack-utils
  node-stealthy-require node-string-decoder node-string-width
  node-strip-ansi node-supports-color node-tap
  node-tap-mocha-reporter node-tap-parser node-tar
  node-text-table node-time-stamp node-tmatch
  node-tough-cookie node-typedarray-to-buffer
  node-unique-filename node-universalify node-util-deprecate
  node-validate-npm-package-license
  node-validate-npm-package-name node-wcwidth.js
  node-webidl-conversions node-whatwg-fetch node-which
  node-wide-align node-wrappy node-write-file-atomic node-ws
  node-yallist rpcsvc-proto
Suggested packages:
  binutils-doc debian-keyring g++-multilib g++-11-multilib
  gcc-11-doc gcc-multilib autoconf automake libtool flex bison
  gcc-doc gcc-11-multilib gcc-11-locales git-daemon-run
  | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb
  git-cvs git-mediawiki git-svn glibc-doc bzr libjs-angularjs
  libssl-doc libstdc++-11-doc make-doc node-nyc
The following NEW packages will be installed:
  binutils binutils-common binutils-x86-64-linux-gnu
  build-essential dpkg-dev fakeroot g++ g++-11 gcc gcc-11 git
  git-man gyp libalgorithm-diff-perl libalgorithm-diff-xs-perl
  libalgorithm-merge-perl libasan6 libatomic1 libbinutils
  libc-dev-bin libc-devtools libc6-dev libcc1-0 libcrypt-dev
  libctf-nobfd0 libctf0 libdpkg-perl liberror-perl libfakeroot
  libfile-fcntllock-perl libgcc-11-dev libitm1 libjs-events
  libjs-inherits libjs-is-typedarray libjs-psl
  libjs-source-map libjs-sprintf-js libjs-typedarray-to-buffer
  liblsan0 libnode-dev libnsl-dev libquadmath0 libssl-dev
  libstdc++-11-dev libtirpc-dev libtsan0 libubsan1 libuv1-dev
  linux-libc-dev lto-disabled-list make manpages-dev node-abab
  node-abbrev node-agent-base node-ansi-regex node-ansi-styles
  node-ansistyles node-aproba node-archy node-are-we-there-yet
  node-argparse node-arrify node-asap node-asynckit
  node-balanced-match node-brace-expansion node-builtins
  node-cacache node-chalk node-chownr node-clean-yaml-object
  node-cli-table node-clone node-color-convert node-color-name
  node-colors node-columnify node-combined-stream
  node-commander node-console-control-strings
  node-copy-concurrently node-core-util-is node-coveralls
  node-cssom node-cssstyle node-debug node-decompress-response
  node-defaults node-delayed-stream node-delegates node-depd
  node-diff node-encoding node-end-of-stream node-err-code
  node-escape-string-regexp node-esprima node-events
  node-fancy-log node-fetch node-foreground-child
  node-form-data node-fs-write-stream-atomic node-fs.realpath
  node-function-bind node-gauge node-get-stream node-glob
  node-got node-graceful-fs node-growl node-gyp node-has-flag
  node-has-unicode node-hosted-git-info node-https-proxy-agent
  node-iconv-lite node-iferr node-imurmurhash
  node-indent-string node-inflight node-inherits node-ini
  node-ip node-ip-regex node-is-buffer node-is-plain-obj
  node-is-typedarray node-isarray node-isexe node-js-yaml
  node-jsdom node-json-buffer node-json-parse-better-errors
  node-jsonparse node-kind-of node-lcov-parse
  node-lodash-packages node-log-driver node-lowercase-keys
  node-lru-cache node-mime node-mime-types node-mimic-response
  node-minimatch node-minimist node-minipass node-mkdirp
  node-move-concurrently node-ms node-mute-stream
  node-negotiator node-nopt node-normalize-package-data
  node-npm-bundled node-npm-package-arg node-npmlog
  node-object-assign node-once node-opener node-osenv
  node-p-cancelable node-p-map node-path-is-absolute
  node-process-nextick-args node-promise-inflight
  node-promise-retry node-promzard node-psl node-pump
  node-punycode node-quick-lru node-read
  node-read-package-json node-readable-stream node-resolve
  node-retry node-rimraf node-run-queue node-safe-buffer
  node-semver node-set-blocking node-signal-exit node-slash
  node-slice-ansi node-source-map node-source-map-support
  node-spdx-correct node-spdx-exceptions
  node-spdx-expression-parse node-spdx-license-ids
  node-sprintf-js node-ssri node-stack-utils
  node-stealthy-require node-string-decoder node-string-width
  node-strip-ansi node-supports-color node-tap
  node-tap-mocha-reporter node-tap-parser node-tar
  node-text-table node-time-stamp node-tmatch
  node-tough-cookie node-typedarray-to-buffer
  node-unique-filename node-universalify node-util-deprecate
  node-validate-npm-package-license
  node-validate-npm-package-name node-wcwidth.js
  node-webidl-conversions node-whatwg-fetch node-which
  node-wide-align node-wrappy node-write-file-atomic node-ws
  node-yallist npm rpcsvc-proto
The following packages will be upgraded:
  libssl3

Check the version of NPM installed.

npm -v

Update NPM to the latest version

Run the following command to update NPM.

npm update

Uninstall NodeJS on Ubuntu

To remove NodeJS from your system, simply run the command below.

sudo apt remove nodejs

Congratulations! you have reached the end of our article.

Read more on Node JS Documentation

LEAVE A REPLY

Please enter your comment!
Please enter your name here