Skip to content

Instantly share code, notes, and snippets.

@therightstuff
Created September 29, 2022 05:34
Show Gist options
  • Save therightstuff/460c0b10ba957778065ae6569ab2daf3 to your computer and use it in GitHub Desktop.
Save therightstuff/460c0b10ba957778065ae6569ab2daf3 to your computer and use it in GitHub Desktop.
Make nvm's node and npm available to the root user
#!/bin/bash
nvm_version="$1"
if [ -z "$nvm_version" ]; then
 echo "desired nvm version must be provided eg. v14.16.0, try providing the output of 'nvm version'"
 exit 1
fi
node_link="/usr/local/bin/node"
npm_link="/usr/local/bin/npm"
sudo rm "$node_link" "$npm_link"
sudo ln -s "$NVM_DIR/versions/node/${nvm_version}/bin/node" "$node_link"
sudo ln -s "$NVM_DIR/versions/node/${nvm_version}/bin/npm" "$npm_link"
ls -l "$node_link" "$npm_link"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment