Skip to content

added task to uninstall before installing new version - allows change…#14

Open
fubarhouse wants to merge 1 commit intonodesource:masterfrom
fubarhouse:master
Open

added task to uninstall before installing new version - allows change…#14
fubarhouse wants to merge 1 commit intonodesource:masterfrom
fubarhouse:master

Conversation

@fubarhouse
Copy link

Allow function to change versions of Node.js if the nodejs version variable changes to allow seamless porting between the available versions.

Tested with DrupalVM on provision, and reprovision between both versions, and has no effect when install hasn't been previously executed from the playbook.


- name: Uninstall existing installations of Node.js
apt: name=nodejs state=absent

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some way of making this check it is necessary? It would be way too excessive to have node reinstall itself every time we run through ansible.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since posting this issue I've created my own Ansible implementation of NVM and I no longer use nodesource.

If you were to do so, you should check for an existing install, register a variable with the currently installed version and provide some logic to determine if it should be uninstalled first.

zaheerquodroid added a commit to QuoDroid-Default/multi-cloud-deployer that referenced this pull request Mar 11, 2026
2026 best practice: Remove existing Node.js before upgrading versions.

Problem:
- Ubuntu 22.04 ships with Node.js v12.22.9 from default repositories
- apt with state: present won't upgrade already-installed packages
- NodeSource repository was added but old version remained

Solution:
- Remove old nodejs and npm packages with purge and autoremove
- Then install Node.js 20 from NodeSource repository
- This ensures clean upgrade from v12 to v20

References:
- NodeSource upgrade guide: https://nodesource.com/blog/Update-Node.js-versions-on-linux
- Ansible best practice: nodesource/ansible-nodejs-role#14

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants