How to set default Node.js, npm, and npx version in SSH
Hawk Host supports a variety of Node.js versions. By default, node, npm, and npx point to the system’s default version. In many cases, you can specify the full paths, for example, npm:
Node.js 24:
/opt/alt/alt-nodejs24/root/bin/npmProblem
Section titled “Problem”You may encounter cases, such as with Vite, where it utilizes the operating system’s node version rather than the version of node associated with the npm binary you used.
Solution
Section titled “Solution”You can fix this by adjusting your $PATH to use your desired versions of node, npm, and npx. For example, if you wished to use our Node.js 24 versions you would do the following:
-
Connect to your hosting account via SSH (How do I log into SSH (shared / cloud web hosting?)
-
Add the following line to your
~/.bashrcfile:Terminal window export PATH="/opt/alt/alt-nodejs24/root/bin:$PATH" -
Reload your shell configuration:
Terminal window source ~/.bashrc -
Verify the changes:
Terminal window node -vnpm -vnpx -v
This will add the Node.js 24 binary path to the beginning of your $PATH, ensuring that the system uses the correct versions of node, npm, and npx.
If you require a different version, simply replace alt-nodejs24 with the desired version in the path. For a list of available Node.js versions and their binary paths, see our Available Node.js versions.