Skip to content

Improve purge_and_reinstall_nodejs.sh to be OS/arch agnostic with install options#27

Merged
djeada merged 3 commits intomasterfrom
copilot/improve-npm-purge-script
Jan 23, 2026
Merged

Improve purge_and_reinstall_nodejs.sh to be OS/arch agnostic with install options#27
djeada merged 3 commits intomasterfrom
copilot/improve-npm-purge-script

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 23, 2026

The original script was hardcoded for linux-x64 and always reinstalled the latest version. Refactored to support multiple platforms and provide flexibility for distro vs upstream Node.js versions.

Changes

Platform Detection

  • OS detection: Linux, macOS, Windows
  • Architecture mapping: x64, arm64, armv7l, x86, ppc64le, s390x
  • Package manager detection: apt, dnf, yum, pacman, zypper, apk, brew

New CLI Options

  • --distro — Install via system package manager (distro-supported version)
  • --latest — Install newest from nodejs.org
  • --lts — Install latest LTS from nodejs.org
  • --version VERSION — Install specific version
  • --purge-only — Only purge, skip reinstall
  • --dry-run, --verbose, --skip-user-cleanup

Code Quality

  • Uses jq for JSON parsing when available, with grep fallback
  • Cross-platform user directories (/home vs /Users)
  • Secure glob handling via find instead of shell expansion
  • Passes shellcheck

Usage

# Install distro-packaged version
./purge_and_reinstall_nodejs.sh --distro

# Install latest from nodejs.org (globally newest)
./purge_and_reinstall_nodejs.sh --latest

# Install LTS version
./purge_and_reinstall_nodejs.sh --lts

# Preview without changes
./purge_and_reinstall_nodejs.sh --dry-run --verbose
Original prompt

This section details on the original issue you should resolve

<issue_title>improve, make more general and agnostic script to purge npm, add option to install newest available (supported officially for distor vs globally newest)</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 23, 2026 20:58
…gnostic

Co-authored-by: djeada <37275728+djeada@users.noreply.github.com>
…t, and JSON parsing

Co-authored-by: djeada <37275728+djeada@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve npm purge script for general use and version installation Improve purge_and_reinstall_nodejs.sh to be OS/arch agnostic with install options Jan 23, 2026
Copilot AI requested a review from djeada January 23, 2026 21:01
@djeada djeada marked this pull request as ready for review January 23, 2026 21:02
@djeada djeada merged commit a514d6e into master Jan 23, 2026
@djeada djeada deleted the copilot/improve-npm-purge-script branch January 23, 2026 21:16
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.

improve, make more general and agnostic script to purge npm, add option to install newest available (supported officially for distor vs globally newest)

2 participants