How can I install npm and Node.js on Ubuntu?

Could you check if npm is already on your system ? If so, update it. That might work.

npm -v
sudo npm install npm@latest -g

Okay, I see in your edited post that npm is not there. I would recommend a quick update of your Ubuntu system.

sudo apt-get update && sudo apt-get -y upgrade

And then install Node.js again:

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs

Note, the command above is for Node.js version 9, but replace it with 8 if you need that.


TL;DR

nodejs needs libssl1.0-dev, which cannot be installed when libcurl4-openssl-dev or libssl-dev are already installed.

The solution is to ununinstall libcurl4-openssl-dev and libssl-dev, or install libssl1.0-dev which forces the others to be removed.

Full Story

I had the same problem, so I tried to manually install each package it complains about along the way.

$ sudo apt install npm
...
The following packages have unmet dependencies:
 npm : Depends: node-gyp (>= 0.10.9) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
$ sudo apt install node-gyp
...
The following packages have unmet dependencies:
 node-gyp : Depends: nodejs-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
$ sudo apt install nodejs-dev
...
The following packages have unmet dependencies:
 nodejs-dev : Depends: libssl1.0-dev (>= 1.0.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
$ sudo apt install libssl1.0-dev
...
The following packages will be REMOVED:
  libcurl4-openssl-dev libssl-dev
The following NEW packages will be installed:
  libssl1.0-dev
0 to upgrade, 1 to newly install, 2 to remove and 0 not to upgrade.
Need to get 1,364 kB of archives.
After this operation, 1,017 kB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://au.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libssl1.0-dev amd64 1.0.2n-1ubuntu5.1 [1,364 kB]
Fetched 1,364 kB in 4s (368 kB/s)
(Reading database ... 323301 files and directories currently installed.)
Removing libcurl4-openssl-dev:amd64 (7.58.0-2ubuntu3.3) ...
Removing libssl-dev:amd64 (1.1.0g-2ubuntu4.1) ...
Selecting previously unselected package libssl1.0-dev:amd64.
(Reading database ... 323196 files and directories currently installed.)
Preparing to unpack .../libssl1.0-dev_1.0.2n-1ubuntu5.1_amd64.deb ...
Unpacking libssl1.0-dev:amd64 (1.0.2n-1ubuntu5.1) ...
Setting up libssl1.0-dev:amd64 (1.0.2n-1ubuntu5.1) ...
Processing triggers for man-db (2.8.3-2) ...

And voilà:

$ sudo apt install npm
...
The following additional packages will be installed:
  gyp libc-ares2 libhttp-parser2.7.1 libjs-async libjs-inherits libjs-node-uuid libuv1 libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-balanced-match node-block-stream
  node-brace-expansion node-builtin-modules node-combined-stream node-concat-map node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fs.realpath node-fstream node-fstream-ignore
  node-github-url-from-git node-glob node-graceful-fs node-gyp node-hosted-git-info node-inflight node-inherits node-ini node-is-builtin-module node-isexe 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-path-is-absolute node-pseudomap node-qs
  node-read node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-slide node-spdx-correct node-spdx-expression-parse node-spdx-license-ids node-tar node-tunnel-agent
  node-underscore node-validate-npm-package-license node-which node-wrappy node-yallist nodejs nodejs-dev nodejs-doc
Suggested packages:
  node-hawk node-aws-sign node-oauth-sign node-http-signature
The following NEW packages will be installed:
  gyp libc-ares2 libhttp-parser2.7.1 libjs-async libjs-inherits libjs-node-uuid libuv1 libuv1-dev node-abbrev node-ansi node-ansi-color-table node-archy node-async node-balanced-match node-block-stream
  node-brace-expansion node-builtin-modules node-combined-stream node-concat-map node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fs.realpath node-fstream node-fstream-ignore
  node-github-url-from-git node-glob node-graceful-fs node-gyp node-hosted-git-info node-inflight node-inherits node-ini node-is-builtin-module node-isexe 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-path-is-absolute node-pseudomap node-qs
  node-read node-read-package-json node-request node-retry node-rimraf node-semver node-sha node-slide node-spdx-correct node-spdx-expression-parse node-spdx-license-ids node-tar node-tunnel-agent
  node-underscore node-validate-npm-package-license node-which node-wrappy node-yallist nodejs nodejs-dev nodejs-doc npm
0 to upgrade, 74 to newly install, 0 to remove and 0 not to upgrade.
Need to get 8,422 kB of archives.
After this operation, 40.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Here's a pretty good guide of getting up and running with the latest version of Node.js using Ubuntu:

How To Install Node.js on Ubuntu 18.04

The guide covers both the installation of a PPA or, if you're allergic to adding non-official repositories to your Ubuntu installation, it also tells you how you can download and run nvm, which will do the heavy lifting of getting a local instance of whichever version of Node.js you choose running in your /home directory.