Not that I am really happy with having had to do this, but...
(env: Ubuntu 18.04, ansible 2.6.1, host: macOS )
from https://github.com/nodesource/distributions/blob/master/README.md#debinstall
- name: install node
shell: |
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - && sudo apt-get install -y nodejs
result:
> vagrant@vagrant:~$ node --version
v10.15.2
and npm
must have come along too:
vagrant@vagrant:~$ npm --version
6.4.1
At the time I ran this, https://www.npmjs.com/package/npm was showing 6.8.0 as latest, with 6.4.1 being from 6 months before. Node was showing 10.15.2 as latest in 10.x series, dating 5 days before.
btw, I also tried apt-get
but that ended with node 8.x rather than 10.x
And the reason I didn't use an ansible galaxy role is that I didn't see any nodejs ones that seemed to come from well-known authors and with lots of stars and downloads (I am cautious and suspicious).
updating npm
My dev machine had 6.8.0
so I added this:
vars.yml:
versions:
npm: "6.8.0"
playbook.yml:
- name: npm self-update
command: npm install npm@{{ versions.npm }} -g
which got me all the way to:
vagrant@vagrant:~$ npm --version
6.8.0