Created
September 29, 2022 05:34
-
-
Save therightstuff/460c0b10ba957778065ae6569ab2daf3 to your computer and use it in GitHub Desktop.
Make nvm's node and npm available to the root user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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