nvm, npm, node: Command not found

The problem

I had gatsbyjs, node and npm installed on a Debian system. Now I'm getting this error:

-bash: gatsby: command not found

-bash: node: command not found

-bash: npm: command not found

Troubleshooting

  1. Check npm installation using the package manager:

    apt-cache policy npm

    npm:
    Installed: (none)

  2. Check nvm installation:

    nvm --version

    0.39.3

    This means Node JS was installed using Node Version Manager.

  3. Check node versions installed locally through nvm:

    nvm ls

    v14.21.3
    v16.19.0
    v18.14.0
    default -> lts/* (-> N/A)
    node -> stable (-> v18.14.0) (default)
    stable -> 18.14 (-> v18.14.0) (default)

Solution

nvm use stable

Now using node v18.14.0 (npm v9.3.1)