Improve Node.js setup to prevent Debian package conflicts
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
Moves APT pinning for NodeSource to occur before removing existing Debian nodejs packages, ensuring Debian's nodejs is not reinstalled. Cleans up logic for removing conflicting packages and clarifies the order of operations in setup_nodejs.
This commit is contained in:
parent
5ebd30abfd
commit
c8a299e401
@ -3322,13 +3322,25 @@ function setup_nodejs() {
|
|||||||
# Clean up legacy installations (nvm, etc.)
|
# Clean up legacy installations (nvm, etc.)
|
||||||
cleanup_legacy_install "nodejs"
|
cleanup_legacy_install "nodejs"
|
||||||
|
|
||||||
# Remove Debian's nodejs if present (conflicts with NodeSource)
|
# Set APT priority FIRST to prevent Debian nodejs from being installed
|
||||||
if dpkg -l | grep -q "^ii.*nodejs.*dfsg"; then
|
cat >/etc/apt/preferences.d/nodesource <<'EOF'
|
||||||
$STD msg_info "Removing Debian-packaged Node.js (conflicts with NodeSource)"
|
Package: nodejs
|
||||||
$STD apt purge -y nodejs libnode* 2>/dev/null || true
|
Pin: origin deb.nodesource.com
|
||||||
|
Pin-Priority: 600
|
||||||
|
|
||||||
|
Package: *
|
||||||
|
Pin: origin deb.nodesource.com
|
||||||
|
Pin-Priority: 600
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# Remove any existing Debian nodejs BEFORE adding NodeSource repo
|
||||||
|
if dpkg -l 2>/dev/null | grep -q "^ii.*nodejs"; then
|
||||||
|
msg_info "Removing Debian-packaged Node.js (conflicts with NodeSource)"
|
||||||
|
$STD apt purge -y nodejs nodejs-doc libnode* node-* 2>/dev/null || true
|
||||||
$STD apt autoremove -y 2>/dev/null || true
|
$STD apt autoremove -y 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Install dependencies (now protected by APT pinning)
|
||||||
ensure_dependencies curl ca-certificates gnupg
|
ensure_dependencies curl ca-certificates gnupg
|
||||||
|
|
||||||
# Prepare repository (cleanup + validation)
|
# Prepare repository (cleanup + validation)
|
||||||
@ -3343,17 +3355,6 @@ function setup_nodejs() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Set APT priority to prefer NodeSource over Debian repos
|
|
||||||
cat >/etc/apt/preferences.d/nodesource <<'EOF'
|
|
||||||
Package: nodejs
|
|
||||||
Pin: origin deb.nodesource.com
|
|
||||||
Pin-Priority: 600
|
|
||||||
|
|
||||||
Package: *
|
|
||||||
Pin: origin deb.nodesource.com
|
|
||||||
Pin-Priority: 600
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Wait for repo to settle
|
# Wait for repo to settle
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user