Node.js (NodeSource) + npm broken after upgrade / dependency conflicts on DietPi (ARM64)

Hi everyone,
I’m running DietPi on ARM64 raspberry pi 4b and I’ve run into a persistent issue with Node.js + npm.

:gear: Current setup
DietPi (latest)
ARM64 system
Node.js installed via NodeSource (v22.22.2)
npm is partially broken / inconsistent

:red_exclamation_mark: Problem description
I originally tried to install npm via apt, which led to dependency conflicts between:
Debian npm package (node-* dependencies)
NodeSource nodejs
After cleanup attempts, the system now has:
Node.js:

node -v → working (NodeSource 22.22.2)
npm:
npm -v sometimes works (10.9.7)
but fails when upgrading:

MODULE_NOT_FOUND: promise-retry
Cannot find module inside /usr/lib/node_modules/npm

:magnifying_glass_tilted_left: Observed state

which npm → /usr/bin/npm

/usr/lib/node_modules/npm exists but seems incomplete/broken

:test_tube: What I already tried

apt remove npm (confirmed not installed)
apt install --reinstall nodejs
dpkg --configure -a
apt --fix-broken install
manual removal of /usr/lib/node_modules/npm
reinstall NodeSource Node.js

:cross_mark: Result
Node.js works, but npm remains unstable or missing dependencies after upgrade attempts.

:red_question_mark: Question
What is the correct and stable way on DietPi to:
fully clean Node.js + npm (NodeSource version)
avoid Debian npm conflicts
ensure npm works properly with Node 22
Is it recommended to:
use NodeSource only?
switch to nvm instead on DietPi?
or reinstall via DietPi optimized method?
Any guidance for a clean and stable setup would be appreciated.
Thanks! :folded_hands:

is there a possibility to install a specific nodejs version like 22 with dietpi?

Kinda. dietpi-software executes this script https://raw.githubusercontent.com/MichaIng/nodejs-linux-installer/master/node-install.sh which supports some parameters, like

 -v, --version <version>   Install specific version with <version> like "v15.5.1"

So you could download the script on you own and run it with the -v option.

Or you just use a manager like n or nvm

Possible to make a option available in dietpi software installer to select the version?

This is not planned and currently we don’t have resources for this.

The repo has some instructions/examples: GitHub - MichaIng/nodejs-linux-installer: This is a universal Node.js installer for Linux. · GitHub

What I planned is the implement an --lts flag, to download the latest LTS version, and do that by default in DietPi. But a version choice for dietpi-software is out of scope.

So the NodeSource package ships an npm version that depends on promise-retry but not that module? Were somehow Node.js instances mixed, or is this a bug to report to NodeSource?