Node.js is very popular and is available in all popular platforms including Ubuntu. It is also very fast-moving and some Linux distributions including Ubuntu for example does not provide the latest version of Node.js in their application repository.

If you require the latest or specific version of Node.js, you can install from NodeSource's PPA.

Steps to install Ubuntu's officially supported Node.js:

  1. Launch terminal.
  2. Update apt's package list.
    $ sudo apt update
    [sudo] password for user: 
    Hit:1 http://my.archive.ubuntu.com/ubuntu eoan InRelease                  
    Hit:2 http://security.ubuntu.com/ubuntu eoan-security InRelease           
    Hit:3 http://my.archive.ubuntu.com/ubuntu eoan-updates InRelease
    Hit:4 http://my.archive.ubuntu.com/ubuntu eoan-backports InRelease
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    All packages are up to date.
  3. Install nodejs package.
    $ sudo apt install --assume-yes nodejs
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following additional packages will be installed:
      libc-ares2 libnode64 libuv1 nodejs-doc
    Suggested packages:
      npm
     ##### snipped
  4. Install Node.js package manager (npm).
    $ sudo apt install --assume-yes npm
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following additional packages will be installed:
      gyp javascript-common libjs-inherits libjs-is-typedarray libnode-dev
      libpython-stdlib libpython2-stdlib libpython2.7-minimal
      libpython2.7-stdlib libssl-dev libuv1-dev node-abbrev node-ajv
      node-ansi node-ansi-align node-ansi-regex node-ansi-styles
      node-ansistyles node-aproba node-archy node-are-we-there-yet node-asn1
      node-assert-plus node-asynckit node-aws-sign2 node-aws4
      node-balanced-match node-bcrypt-pbkdf node-bluebird node-boxen
      node-brace-expansion node-builtin-modules node-builtins node-cacache
      node-call-limit node-camelcase node-caseless node-chalk node-chownr
      node-cli-boxes node-cliui node-clone node-color-convert node-color-name
      node-combined-stream node-concat-map node-concat-stream
      node-config-chain node-console-control-strings node-copy-concurrently
      node-core-util-is node-cross-spawn node-cyclist node-dashdash
      node-decamelize node-decompress-response node-deep-extend node-defaults
      node-delayed-stream node-delegates node-detect-indent
      node-detect-newline node-duplexer3 node-duplexify node-ecc-jsbn
      node-editor node-encoding node-end-of-stream node-errno
      node-escape-string-regexp node-execa node-extend node-extsprintf
      node-fast-deep-equal node-find-up node-flush-write-stream
      node-forever-agent node-form-data node-from2 node-fs-vacuum
      node-fs-write-stream-atomic node-fs.realpath node-gauge
      node-get-caller-file node-get-stream node-getpass node-glob node-got
      node-graceful-fs node-gyp node-har-schema node-har-validator
      node-has-flag node-has-symbol-support-x node-has-to-string-tag-x
      node-has-unicode node-hosted-git-info node-http-signature
      node-iconv-lite node-iferr node-import-lazy node-imurmurhash
      node-inflight node-inherits node-ini node-invert-kv
      node-is-builtin-module node-is-npm node-is-object node-is-plain-obj
      node-is-retry-allowed node-is-stream node-is-typedarray node-isarray
      node-isexe node-isstream node-isurl node-jsbn
      node-json-parse-better-errors node-json-schema
      node-json-schema-traverse node-json-stable-stringify
      node-json-stringify-safe node-jsonify node-jsonparse node-jsonstream
      node-jsprim node-latest-version node-lazy-property node-lcid
      node-libnpx node-locate-path node-lockfile node-lowercase-keys
      node-lru-cache node-mem node-mime-types node-mimic-fn
      node-mimic-response node-minimatch node-minimist node-mississippi
      node-mkdirp node-move-concurrently node-mute-stream node-node-uuid
      node-nopt node-normalize-package-data node-npm-package-arg
      node-npm-run-path node-npmlog node-oauth-sign node-object-assign
      node-once node-opener node-os-locale node-osenv node-p-cancelable
      node-p-finally node-p-limit node-p-locate node-p-timeout
      node-package-json node-parallel-transform node-path-exists
      node-path-is-absolute node-path-is-inside node-performance-now
      node-prepend-http node-process-nextick-args node-promise-inflight
      node-promzard node-proto-list node-prr node-pump node-pumpify
      node-punycode node-qs node-qw node-rc node-read node-read-package-json
      node-readable-stream node-registry-auth-token node-registry-url
      node-request node-require-directory node-require-main-filename
      node-resolve-from node-retry node-rimraf node-run-queue
      node-safe-buffer node-semver node-semver-diff node-set-blocking
      node-sha node-shebang-command node-shebang-regex node-signal-exit
      node-slash node-slide node-sorted-object node-spdx-correct
      node-spdx-expression-parse node-spdx-license-ids node-sshpk node-ssri
      node-stream-each node-stream-iterate node-stream-shift
      node-string-decoder node-string-width node-strip-ansi node-strip-eof
      node-strip-json-comments node-supports-color node-tar node-term-size
      node-text-table node-through node-through2 node-timed-out
      node-tough-cookie node-tunnel-agent node-tweetnacl node-typedarray
      node-uid-number node-unique-filename node-unpipe node-uri-js
      node-url-parse-lax node-url-to-options node-util-deprecate node-uuid
      node-validate-npm-package-license node-validate-npm-package-name
      node-verror node-wcwidth.js node-which node-which-module
      node-wide-align node-widest-line node-wrap-ansi node-wrappy
      node-write-file-atomic node-xdg-basedir node-xtend node-y18n
      node-yallist node-yargs node-yargs-parser python python-minimal
      python-pkg-resources python2 python2-minimal python2.7
      python2.7-minimal
    Suggested packages:
      apache2 | lighttpd | httpd libssl-doc python-doc python-tk
      python-setuptools python2-doc python2.7-doc binfmt-support
     ##### snipped
  5. Check installed version of nodejs and npm.
    $ nodejs -v
    v10.15.2
    $ npm -v
    5.8.0
Discuss the article:

Comment anonymously. Login not required.

Share!