Skip to content

Commit 32f6a53

Browse files
committed
Switch Node install to NVM to control version
1 parent d900d92 commit 32f6a53

1 file changed

Lines changed: 37 additions & 13 deletions

File tree

ansible/roles/pwa-html/tasks/main.yml

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
---
2-
- name: Download nodesource APT repo script
2+
- name: Install dependencies for nvm
3+
apt:
4+
pkg:
5+
- curl
6+
- zip
7+
state: present
8+
update_cache: yes
9+
10+
- name: Download nvm install script
311
get_url:
4-
url: https://deb.nodesource.com/setup_22.x
5-
dest: /tmp/setup-node-apt-source.sh
6-
mode: 777
12+
url: https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh
13+
dest: /tmp/install-nvm.sh
14+
mode: "0755"
715

8-
- name: Setup nodesoure APT repo
9-
shell: /tmp/setup-node-apt-source.sh
16+
- name: Install nvm
17+
shell: /tmp/install-nvm.sh
1018
args:
11-
creates: /etc/apt/sources.list.d/nodesource.list
19+
creates: /root/.nvm/nvm.sh
1220
executable: bash
21+
environment:
22+
HOME: /root
1323

14-
- name: Install Packages
15-
apt:
16-
pkg:
17-
- nodejs
18-
- zip
19-
state: latest
24+
- name: Install Node.js v22.21.1 using nvm
25+
shell: |
26+
. /root/.nvm/nvm.sh
27+
nvm install v22.21.1
28+
nvm alias default v22.21.1
29+
args:
30+
creates: /root/.nvm/versions/node/v22.21.1
31+
executable: bash
32+
environment:
33+
HOME: /root
34+
35+
- name: Create symlinks for node and npm in /usr/local/bin
36+
shell: |
37+
. /root/.nvm/nvm.sh
38+
ln -sf $(which node) /usr/local/bin/node
39+
ln -sf $(which npm) /usr/local/bin/npm
40+
args:
41+
executable: bash
42+
environment:
43+
HOME: /root
2044

2145
- name: Install Workbox-CLI
2246
npm:

0 commit comments

Comments
 (0)