I suspect you are using n or nvm or fnm or another node manager & the actual version of Node you are running node-red with is < v20. To prove this, open the "System Info" on your node-red editor:
Additionally, please clarify how you installed Node-RED and how you run it? It looks like you are running Node-RED as root - this is REALLY not advisable.
You have some kind of node version manager installed & that is confusing the situation and causing the MSSQL node installation issue. When you entered node -v it reported v20, but as you can clearly see from System Info, Node-RED is running on Node v18.
You are running as root, again, unless you absoultely need root or understand the implications, you should run this as a regular user.
My recommendation to fix all of your issues.
Remove n, nvm, fnm or any other Node Version manager you have installed
Install Node-RED using the official installer script