Search code examples
node.jsnpmnvm

nvm installed node and npm, get npm not found


I download the latest lts version of node from nvm (v16.18.0) but I am getting an error /bin/sh: 1: npm: not found when I try to run a script with pm2.

which npm returns /home/ubuntu/.nvm/versions/node/v16.18.0/bin/npm, I believe the issue can be solved with creating a symlink but nothing is working for me. Any help is appreciated!


Solution

  • I was able to solve it with:

    sudo ln -s "$(which node)" "/usr/local/bin/node"
    sudo ln -s "$(which npm)" "/usr/local/bin/npm"