Resolving Node and npm Path Issues with NVM on Ubuntu
Jun
26
Resolving Node and npm Path Issues with NVM on Ubuntu
Encountering repeated 'command not found' errors for 'pm2', 'node', and 'npm' commands after SSH sessions on my Ubuntu server prompted me to investigate the Node Version Manager (NVM) setup. The problem was that NVM hadn't properly set up environment settings, which meant I couldn't access these commands globally. To fix this, I made sure NVM was correctly set up in my `.bashrc` file, checked it was working with `nvm --version`, and reinstalled Node.js using `nvm install node` to make sure everything was set up right. I also set Node.js as the default version with `nvm alias default node` and checked if global packages like 'pm2' were installed with `npm list -g pm2`. These steps helped me get these commands working consistently during SSH sessions.
This experience highlighted the importance of getting your environment settings right, especially when using NVM to manage different versions of Node.js. By fixing these setup issues promptly, I got back to using essential development tools without interruptions, and I'm better prepared to handle similar issues in the future.