Skip to content

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:

Terminal window
/opt/alt/alt-nodejs24/root/bin/npm

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.

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:

  1. Connect to your hosting account via SSH (How do I log into SSH (shared / cloud web hosting?)

  2. Add the following line to your ~/.bashrc file:

    Terminal window
    export PATH="/opt/alt/alt-nodejs24/root/bin:$PATH"
  3. Reload your shell configuration:

    Terminal window
    source ~/.bashrc
  4. Verify the changes:

    Terminal window
    node -v
    npm -v
    npx -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.