Sample Header Ad - 728x90

Recommended way of removing virtual package 'nodejs-legacy' on Debian headless server

0 votes
1 answer
32 views
I'm upgrading NodeJS and NPM to the latest LTS on my aging Debian 11 (bullseye) server. I purged the distro's stock *nodejs* and *npm* packages and dependencies, and successfully installed NodeJS v22.15.0 and NPM v10.9.2 using [nodesource](https://github.com/nodesource/distributions) . I'm now attempting to remove the *nodejs-legacy* package which — I'm assuming — is likely not needed anymore, but both *apt* and *apt-get* (they behave exactly the same in this regard) complain that:
$ sudo apt remove nodejs-legacy
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Virtual packages like 'nodejs-legacy' can't be removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
As far as I understand, virtual packages only define dependencies and/or install configuration files. How come a package, even "virtual" — or whatever they want to call it ­— cannot be uninstalled? Can't *apt* (or *apt-get*) simply update the package database and/or remove said files? This particular package is not even part in any dependency:
$ sudo apt depends nodejs-legacy

$ sudo apt rdepends nodejs-legacy
I guess I could just leave it there since it doesn't seem to conflict with anything else (so far, that is). But I'd rather keep my servers free of old garbage lying around. What is the recommended way of ridding a Debian system of old virtual packages that are not needed anymore?
Asked by mesr (429 rep)
Apr 26, 2025, 06:34 PM
Last activity: Apr 26, 2025, 07:07 PM