Using Node.js without admin rights - sh: node: command not found

I've been following this guide (https://theshravan.net/blog/how-to-use-node-and-npm-without-installation-or-admin-rights/) to try to use Node.js on my work computer. The guide is for windows but most of the steps are the same for mac. I don't have admin rights so I'm using the binary to use node. When I run npm -v and node -v, i get the versions so it looks like everything is working. But, when I try to install packages with npm I get sh: node: command not found

My PATH looks like this: PATH=$PATH:Tools/nodejs


The linked guide doesn't really help for macOS or Linux because of the different file & folder hierarchy compared to Winodws.

I recommend the followwing:

  1. Download either the LTS or the latest version of node.js (both are direct download links!). Node.js download site: Downloads (no direct link).
  2. Extract the node-v(ersion)x.y.z-darwin-x64.tar.gz and rename the resulting folder to node
  3. Create a new folder bin in your home folder
  4. Move the node folder to the bin folder
  5. Add the following line to your .bash_profile:

    export PATH="$PATH:$HOME/bin/node/bin"
    

There is no need to download npm additionally because it's already included in the node archive.


If you want to install a newer version simply download the new node-v(ersion)x.y.z-darwin-x64.tar.gz file, extract it and move its content to ~/bin/node/ replacing the old files and folders.