ChatGPT is not a reliable source to solve issues. In many many cases the AI gives you broken answers. In fact, in most cases, you are better off asking your question here or searching Google and bypassing ChatGPT completely and getting help here.
The proper way to set up NodeJS and such on Ubuntu is fairly easy. Both Digital Ocean and Linode have good guides for installing NodeJS on Ubuntu 22.04, but in principle this is the process for installing the latest supported version(s) of NodeJS:
Use NodeSource archives for a latest release of Node
Download the setup script.
cd ~
curl -sL https://deb.nodesource.com/setup_19.x -o nodesource_setup.sh
Replace 19.x
with the specific major version of NODE you're looking to install - 19 is the current latest as of this post being written.
Execute the setup script
sudo bash ~/nodesource_setup.sh
Once the script is done running, install via APT.
sudo apt update && sudo apt install nodejs
That will set up Node and NPM on your system.
Note that this is specifically for supported Ubuntu releases, and may not immediately work with newer Ubuntu releases which have just come out, because these repositories and this mechanism are a NodeSource approach/solution and they are not immediately up to date with newer Ubuntu releases as they come out.